From eb715b20296385688a11c6e7c4874f8339b90d46 Mon Sep 17 00:00:00 2001 From: "Vivek M. Chawla" Date: Wed, 6 Mar 2019 20:25:34 -0800 Subject: [PATCH] test(testenv): Update test/helpers/init.js Add environment variables that are set during test initialization to ensure portability between local and CI Build environments Related to: #133 --- test/helpers/init.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/helpers/init.js b/test/helpers/init.js index f8e35e6..bf653fb 100644 --- a/test/helpers/init.js +++ b/test/helpers/init.js @@ -1,2 +1,19 @@ -const path = require('path') -process.env.TS_NODE_PROJECT = path.resolve('test/tsconfig.json') +const path = require('path'); +const del = require('del'); + +// Set environment vars in the current process. +process.env.TS_NODE_PROJECT = path.resolve('test/tsconfig.json'); // Part of the boilerplate code. +process.env.FALCON_COMMAND_RUNNER = path.resolve('bin/run'); // Path to the command runner utility. +process.env.FALCON_TEST_TEMPDIR = path.resolve('test/temp'); // Path to the temp directory used during tests. + +// Delete everything inside of the Falcon Test Temp Directory EXCEPT .gitignore +del.sync( + [ + `${process.env.FALCON_TEST_TEMPDIR}/**/*`, // Delete everything from the Test Temp Directory + `!${process.env.FALCON_TEST_TEMPDIR}/.gitignore` // EXCEPT the .gitignore file. + ], + { + dryRun: false, // Determines if the command will actually delete or just return an array of what WOULD be deleted. + dot: true // Determines if dotfiles are deleted or not. + } +);