Merge pull request #558 from embark-framework/bug_fix/console-dir-test
Fix testing a directory without ending slash
This commit is contained in:
commit
9574562602
|
@ -32,14 +32,23 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function getFiles(next) {
|
function checkIfDir(next) {
|
||||||
if (filePath.substr(-1) !== '/') {
|
if (filePath.substr(-1) === '/') {
|
||||||
return fs.access(filePath, (err) => {
|
return next(null, null);
|
||||||
if (err) {
|
}
|
||||||
return next(`File "${filePath}" doesn't exist or you don't have permission to it`.red);
|
fs.stat(filePath, (err, stats) => {
|
||||||
}
|
if (err) {
|
||||||
next(null, [filePath]);
|
return next(`File "${filePath}" doesn't exist or you don't have permission to it`.red);
|
||||||
});
|
}
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
return next(null, null);
|
||||||
|
}
|
||||||
|
next(null, [filePath]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function getFiles(files, next) {
|
||||||
|
if (files) {
|
||||||
|
return next(null, files);
|
||||||
}
|
}
|
||||||
getFilesFromDir(filePath, (err, files) => {
|
getFilesFromDir(filePath, (err, files) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -56,7 +65,7 @@ module.exports = {
|
||||||
global.assert = assert;
|
global.assert = assert;
|
||||||
global.config = test.config.bind(test);
|
global.config = test.config.bind(test);
|
||||||
|
|
||||||
let deprecatedWarning = function() {
|
let deprecatedWarning = function () {
|
||||||
console.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
|
console.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
|
||||||
console.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
|
console.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
|
||||||
process.exit();
|
process.exit();
|
||||||
|
@ -69,7 +78,7 @@ module.exports = {
|
||||||
// Override require to enable `require('Embark/contracts/contractName');`
|
// Override require to enable `require('Embark/contracts/contractName');`
|
||||||
const Module = require('module');
|
const Module = require('module');
|
||||||
const originalRequire = require('module').prototype.require;
|
const originalRequire = require('module').prototype.require;
|
||||||
Module.prototype.require = function(requireName) {
|
Module.prototype.require = function (requireName) {
|
||||||
if (requireName.startsWith('Embark')) {
|
if (requireName.startsWith('Embark')) {
|
||||||
return test.require(...arguments);
|
return test.require(...arguments);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +110,7 @@ module.exports = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
mocha.run(function(fails) {
|
mocha.run(function (fails) {
|
||||||
failures += fails;
|
failures += fails;
|
||||||
// Mocha prints the error already
|
// Mocha prints the error already
|
||||||
eachCb();
|
eachCb();
|
||||||
|
|
Loading…
Reference in New Issue