Skip to content

Commit

Permalink
Normalize variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Varache committed Sep 10, 2018
1 parent b333a68 commit 5f93f57
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/collect_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ const argv = require("yargs")
.alias("d", "dir")
.argv;

/**
* Resolves a unix style variable on windows platforms
* e.g.: $NODE_ENV => process.env.NODE_ENV
* @param {string} variable variable received from argv
*/
function normalizeVariable(variable) {
if (process.platform === "win32" && variable.startsWith("$")) {
return process.env[variable.replace(/$\$/, "")];
}
return variable;
}

/**
* COLLECT TESTS
*/
function collectTests(){
return new Promise((done, error) => {
argv.file = normalizeVariable(argv.file);
argv.dir = normalizeVariable(argv.dir);
var tests = "../test/!(helper|deps|examples|html)/*.js";
if (typeof argv.file === "string"){
tests = `../test/*/${argv.file}.js`;
Expand Down

0 comments on commit 5f93f57

Please sign in to comment.