Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function readImplementedSteps(next) {
this.implementedSteps = [];
mkdirp(this.config.stepDefinitionsDir);
walk.sync(this.config.stepDefinitionsDir, function (filePath) {
if (!fs.lstatSync(filePath).isDirectory()) {
var fileContent = fs.readFileSync(filePath).toString();
var re = /^this\.(Given|When|Then)\((\/|')(.+)(\/|')(\w*)/;
var stepDefinitions = fileContent.split('\n').map(Function.prototype.call, String.prototype.trim)
.filter(function (line) {
return re.test(line);
})
.map(function (line) {
var matches = re.exec(line);
var keyword = matches[1];
var pattern = matches[3];
var isStringPattern = false;
// String Pattern
var dirtyFiles = [],
ignore = options.ignore || [],
files = [];
// If more paths are given with the --source flag
if(source.split(',').length > 1){
var dirtyPaths = source.split(',');
dirtyPaths.forEach(function(dirtyPath){
dirtyFiles = dirtyFiles.concat(require('walkdir').sync(path.resolve(process.cwd(), dirtyPath),{follow_symlinks:true}));
});
}
// Just one path given with the --source flag
else {
source = path.resolve(process.cwd(), source);
dirtyFiles = require('walkdir').sync(source,{follow_symlinks:true}); // tee hee!
}
dirtyFiles.forEach(function(file){
file = path.relative(process.cwd(), file);
var doNotIgnore = _.all(ignore, function(d){
// return true if no part of the path is in the ignore list
return (file.indexOf(d) === -1);
});
if ((file.substr(-2) === 'js') && doNotIgnore) {
files.push(file);
}
});
console.log(files)
return files;
loadpaths.forEach(function(loadpath){
wannaBeSpecs = walkdir.sync(loadpath, { follow_symlinks: true });
for (var i = 0; i < wannaBeSpecs.length; i++) {
var file = wannaBeSpecs[i];
try {
if (fs.statSync(file).isFile()) {
if (!/.*node_modules.*/.test(path.relative(loadpath, file)) &
matcher.test(path.basename(file))) {
specs.push(createSpecObj(file));
}
}
} catch(e) {
// nothing to do here
}
}
});
};
var tasks = [];
var specBaseDir = path.dirname(args.specsInit);
var specDir = args.specsLocation;
// creates an async task that imports a spec, then triggers the next task.
function createTask(spec){
return function(next){
System.import(spec).then(function(){
next();
});
}
}
// Synchronously walk the directory and load all specs
walk.sync(specDir, function(file, stat){
if (/-spec.js$/.test(file)) {
// convert full path to relative path under spec base directory without .js extension
// also, prefix with spec: for jspm alias (defined in test.js)
var spec = file.replace(specBaseDir, '').replace(/^\//, '').replace(/^/, 'spec:').replace(/.js$/, '');
tasks.push(createTask(spec));
}
});
// Load all jasmine tests, then execute the test runner.
async.waterfall(tasks, function(){
window.jasmine.getEnv().execute();
});
})();
const searchForSockets = (socketsPath, maxDepth = 3) => {
if (!fs.existsSync(socketsPath)) {
return []
}
const sockets = []
const options = {
'follow_symlinks': true,
'max_depth': maxDepth
}
// TODO: optimize only diging deeper scoped modues
walkdir.sync(socketsPath, options, (walkPath, stat) => {
if (walkPath.match(/socket.yml$/) && !path.dirname(walkPath).match(/\/\./)) {
const socket = YAML.load(fs.readFileSync(walkPath, 'utf8')) || {}
sockets.push([walkPath, socket])
}
})
return sockets
}
function getAllNodeModules(pathStr) {
let modules = [];
try {
modules = walk.sync(pathStr, {
no_recurse: true
});
} catch (e) {
modules = [];
}
modules.forEach((moduleName) => {
// 私包
if (moduleName[0] === '@') {
modules = modules.concat(getAllNodeModules(`${pathStr}/${moduleName}`));
}
});
return modules;
}
var autoInclude = {
css: '',
jsLib: '',
jsApp: ''
};
if (angus.env !== 'prod') {
autoInclude.css = angus.appConfig.bower.filesNeeded.css
.map(function (filePath) {
filePath = 'assets/bower_components/' + filePath;
return '';
}).join('\n ');
}
walkDir.sync(angus.appPath + '/dist/assets/', {
'max_depth': 1
}, function (filePath) {
if (path.extname(filePath) === '.css') {
filePath = filePath.replace(angus.appPath + path.sep + 'dist' + path.sep, '');
autoInclude.css += '\n ';
}
});
// We could also walk the directory, but we want to make sure that the order of inclusion stays intact
// so we make the script tags manually. If we are on prod, no need to include libraries as
// these are already present inside main.css, which we already include below.
if (angus.env !== 'prod') {
autoInclude.jsLib = angus.appConfig.bower.filesNeeded.js
.map(function (filePath) {
filePath = 'js/bower_components/' + filePath;
return '';
'appName': path.basename(appPath),
'appConfig': appConfig
};
// Load core tasks related to Angus itself
walkDir.sync('./core/gulp/', function (filePath) {
var name = path.basename(filePath, '.js');
gulp.task(name, function (cb) {
gutil.log(gutil.colors.cyan('Running task: ') + gutil.colors.magenta(name));
return require(filePath)(angus, gulp)(cb);
});
});
// Load app tasks which can be run using `angus ` from that app directory
if (fs.existsSync(appPath + '/tasks/')) {
walkDir.sync(appPath + '/tasks/', function (filePath) {
var name = path.basename(filePath, '.js');
gulp.task(name, function (cb) {
gutil.log(gutil.colors.cyan('Running app task: ') + gutil.colors.blue(name));
return require(filePath)(angus, gulp)(cb);
});
});
}
var fullBuildTags = [
'check',
'js',
'clean',
'html',
'assets',
'css'
];
describe('JSHint', function () {
var rcPath = path.join(__dirname, '..', '.jshintrc');
var rcFile = fs.readFileSync(rcPath, 'utf8');
var configuration = JSON.parse(rcFile);
var commonPath = path.join(__dirname, '..');
var files = Array.prototype.concat(
path.join(__dirname, '..', 'bin', 'persona-gmail-bridge.js'),
walk.sync(path.join(__dirname, '..', 'lib')),
walk.sync(path.join(__dirname, '..', 'scripts')),
walk.sync(path.join(__dirname, '..', 'static')),
walk.sync(path.join(__dirname, '..', 'test'))
);
files = files.filter( function(file) {
return (/\.js$/).test(file) && !(/\/i18n\/.*\/messages\.js$/).test(file);
} );
files.forEach(function (file) {
var relativeName = file.substring(commonPath.length);
it(relativeName + ' should pass', function () {
var source = fs.readFileSync(file, 'utf8');
if (!jshint(source, configuration)) {
throw new Error('JSHint failed.\n' + format(jshint.errors));
}
dirtyPaths.forEach(function(dirtyPath){
dirtyFiles = dirtyFiles.concat(require('walkdir').sync(path.resolve(process.cwd(), dirtyPath),{follow_symlinks:true}));
});
}