Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Bump glob to version 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwalz committed Mar 9, 2015
1 parent cabb4c4 commit dd0cdfc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 38 deletions.
63 changes: 26 additions & 37 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var getGlobbedPaths = function(globPatterns, excludes) {
// The output array
var output = [];

// If glob pattern is array so we use each pattern in a recursive way, otherwise we use glob
// If glob pattern is array so we use each pattern in a recursive way, otherwise we use glob
if (_.isArray(globPatterns)) {
globPatterns.forEach(function(globPattern) {
output = _.union(output, getGlobbedPaths(globPattern, excludes));
Expand All @@ -27,25 +27,20 @@ var getGlobbedPaths = function(globPatterns, excludes) {
if (urlRegex.test(globPatterns)) {
output.push(globPatterns);
} else {
glob(globPatterns, {
sync: true
}, function(err, files) {
if (excludes) {
files = files.map(function(file) {
if (_.isArray(excludes)) {
for (var i in excludes) {
file = file.replace(excludes[i], '');
}
} else {
file = file.replace(excludes, '');
var files = glob.sync(globPatterns);
if (excludes) {
files = files.map(function(file) {
if (_.isArray(excludes)) {
for (var i in excludes) {
file = file.replace(excludes[i], '');
}

return file;
});
}

output = _.union(output, files);
});
} else {
file = file.replace(excludes, '');
}
return file;
});
}
output = _.union(output, files);
}
}

Expand All @@ -56,26 +51,20 @@ var getGlobbedPaths = function(globPatterns, excludes) {
* Validate NODE_ENV existance
*/
var validateEnvironmentVariable = function() {
glob('./config/env/' + process.env.NODE_ENV + '.js', {
sync: true
}, function(err, environmentFiles) {
console.log();

if (!environmentFiles.length) {
if (process.env.NODE_ENV) {
console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead'));
} else {
console.error(chalk.red('NODE_ENV is not defined! Using default development environment'));
}

process.env.NODE_ENV = 'development';
var environmentFiles = glob.sync('./config/env/' + process.env.NODE_ENV + '.js');
console.log();
if (!environmentFiles.length) {
if (process.env.NODE_ENV) {
console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead'));
} else {
console.log(chalk.bold('Application loaded using the "' + process.env.NODE_ENV + '" environment configuration'));
console.error(chalk.red('NODE_ENV is not defined! Using default development environment'));
}

// Reset console color
console.log(chalk.white(''));
});
process.env.NODE_ENV = 'development';
} else {
console.log(chalk.bold('Application loaded using the "' + process.env.NODE_ENV + '" environment configuration'));
}
// Reset console color
console.log(chalk.white(''));
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"bower": "~1.3.8",
"grunt-cli": "~0.1.13",
"chalk": "~0.5.1",
"glob": "~4.0.5",
"glob": "~5.0.0",
"async": "~0.9.0",
"nodemailer": "~1.3.0"
},
Expand Down

0 comments on commit dd0cdfc

Please sign in to comment.