Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
// 3rd party modules
const childProcess = require('child_process');
const deferred = require('deferred');
const fs = require('fs');
const path = require('path');
const exec = deferred.promisify(childProcess.exec);
const execFile = deferred.promisify(childProcess.execFile);
const glob = deferred.promisify(require('glob'));
const stat = deferred.promisify(fs.stat);
// Implementation
async function start() {
const imageNames = await getImageNames();
const toolNames = await getToolNames();
const total = imageNames.length * toolNames.length;
let i = 1;
const images = [];
for (const imageName of imageNames) {
let bestScore = 0;
let highestSaving = 0;
let leastLoss = 0;
'use strict';
// 3rd party modules
const childProcess = require('child_process');
const deferred = require('deferred');
const fs = require('fs');
const path = require('path');
const exec = deferred.promisify(childProcess.exec);
const execFile = deferred.promisify(childProcess.execFile);
const glob = deferred.promisify(require('glob'));
const stat = deferred.promisify(fs.stat);
// Implementation
async function start() {
const imageNames = await getImageNames();
const toolNames = await getToolNames();
const total = imageNames.length * toolNames.length;
let i = 1;
const images = [];
for (const imageName of imageNames) {
let bestScore = 0;
let highestSaving = 0;
'use strict';
// 3rd party modules
const childProcess = require('child_process');
const deferred = require('deferred');
const fs = require('fs');
const path = require('path');
const exec = deferred.promisify(childProcess.exec);
const execFile = deferred.promisify(childProcess.execFile);
const glob = deferred.promisify(require('glob'));
const stat = deferred.promisify(fs.stat);
// Implementation
async function start() {
const imageNames = await getImageNames();
const toolNames = await getToolNames();
const total = imageNames.length * toolNames.length;
let i = 1;
const images = [];
for (const imageName of imageNames) {
let bestScore = 0;
let highestSaving = 0;
let leastLoss = 0;
const image = {
// Must not be used on client-side.
'use strict';
var promisify = require('deferred').promisify
, bcrypt = require('bcrypt')
, string = require('../string')
, genSalt = promisify(bcrypt.genSalt), hash = promisify(bcrypt.hash)
, compare = promisify(bcrypt.compare);
module.exports = string.create('password', {
async: true,
min: 5,
pattern: /(?=[\0-\uffff]*\d)(?=[\0-\uffff]*[a-zA-Z])/,
rounds: 10,
compare: function (password, hash) { return compare(password, hash); },
validate: function (value) {
return hash(string.validate.call(this, value), genSalt(this.rounds || 10));
}
});
"use strict";
var promisify = require("deferred").promisify
, fs = require("fs")
, path = require("path")
, resolve = path.resolve
, lstat = promisify(fs.lstat)
, unlink = promisify(fs.unlink)
, rootPath = resolve(__dirname, "./__playground/symlink")
, base = resolve(rootPath, "from")
, regular = resolve(rootPath, "foo")
, deep = resolve(rootPath, "foo/bar");
module.exports = function (t) {
return {
Regular: {
Success: function (a, d) {
t(base, regular)(function () {
return lstat(regular)(function (stats) {
a(stats.isSymbolicLink(), true);
return unlink(regular);
});
}).done(d, d);
""(t, a, d) {
const input = `${ pg }/lib/program.js`
, output = `${ pg }/build.js`
, options = { include: `${ pg }/lib/included`, ignore: [resolve(pg, "not-taken.js")] };
t = promisify(t);
t(input, options)(result => {
const program = runInNewContext(result, {});
a(program.x.name, "x", "Same path require");
a(program.x.getZ().name, "z", "Deferred call");
a(
program.x.getZ(), program.x.getZ(),
"Requiring same object twice, should return same object"
);
a(program.y.z.name, "z", "Require within required module");
a(program.y.z.y.name, "y", "Circular dependency");
a(program.dirjs, "DIR.JS", "Directory with '.js' extension");
a(program.indexed.name, "indexed", "Folder index");
a(program.included.a.name, "included.a", "Manually included #1");
a(program.included.b.name, "included.b", "Manually included #2");
a(program.outer.name, "outer", "Require module up tree");
a(program.outerSubIndex.name, "outer-index", "Require index from sibling directory");
"use strict";
var promisify = require("deferred").promisify
, fs = require("fs")
, path = require("path")
, dirname = path.dirname
, resolve = path.resolve
, lstat = promisify(fs.lstat)
, rmdir = promisify(fs.rmdir)
, rootPath = resolve(__dirname, "./__playground/mkdir")
, regular = resolve(rootPath, "foo")
, existing = resolve(rootPath, "one")
, deep = resolve(rootPath, "foo", "bar");
module.exports = function (t) {
return {
Regular: {
Success: function (a, d) {
t(regular)(function () {
return lstat(regular)(function (stats) {
a(stats.isDirectory(), true);
return rmdir(regular);
});
}).done(d, d);
},
"use strict";
var promisify = require("deferred").promisify
, ee = require("event-emitter")
, fs = require("fs")
, typeByStats = require("../type-by-stats");
var nextTick = process.nextTick
, lstat = promisify(fs.lstat)
, watch = fs.watch
, opts = { persistent: false };
module.exports = function (path, emitter) {
var stats, fileType, listener, watcher, lock, end, clearLock, close;
end = function (err) {
if (emitter) {
emitter.emit("end", err);
close();
}
};
close = function () {
if (emitter) {
watcher.close();
'use strict';
var replace = require('es5-ext/string/#/simple-replace')
, memoize = require('memoizee')
, promisify = require('deferred').promisify
, resolve = require('path').resolve
, readFile = promisify(require('fs').readFile)
, writeFile = promisify(require('fs').writeFile)
, getSnapshot = require('../lib/history')._snapshot
, codify = require('../lib/utils/codify')
, stringify = JSON.stringify, getTpl;
getTpl = memoize(function () {
return readFile(resolve(__dirname, 'export.tpl'), 'utf8');
});
module.exports = function (filename/*, options*/) {
var options = Object(arguments[1]);
return writeFile(resolve(String(filename)), getTpl()(function (tpl) {
var data;
if (options.log) tpl = tpl.replace(/\/\/\$LOG\$/g, '');
data = getSnapshot(options);
'use strict';
var fs = require('fs');
var deferred = require('deferred');
var images = require('./images');
var readFile = deferred.promisify(fs.readFile);
var writeFile = deferred.promisify(fs.writeFile);
/**
* @description
* Read the named JSON file in directory and write it's contents to the named
* member of results.
*
* @inner
* @param {String} directory
* @param {Object} results
* @param {String} name
* @return {Promise}
*/
function read(directory, results, name) {
return readFile(directory + name + '.json')
.then(function(str) {
var json = JSON.parse(str);