Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const npmDownloads = options => {
if (!options.module || typeof options.module !== 'string') {
return Promise.reject(new Error('module name required'));
} else if (/^@/.test(options.module)) {
return Promise.reject(new Error('private modules not supported'));
}
spinner.start(`Fetching ${chalk.bold(options.module)} downloads`);
return fetchDownloadsCount(options)
.then(response => {
return response.map(item => item.body);
})
.then(response => {
spinner.stop();
if (isNonexistentPackage(response)) {
return Promise.reject(new Error('nonexistent package'));
}
printDownloadsCount(options.module, response);
module.exports = function (target, opts) {
if (typeof target !== 'string') {
return Promise.reject(new Error('Expected a `target`'));
}
opts = objectAssign({wait: true}, opts);
var cmd;
var appArgs = [];
var args = [];
var cpOpts = {};
if (Array.isArray(opts.app)) {
appArgs = opts.app.slice(1);
opts.app = opts.app[0];
}
if (process.platform === 'darwin') {
cmd = 'open';
function got(url, opts, cb) {
if (typeof opts === 'function') {
cb = opts;
opts = {};
}
if (cb) {
asCallback(normalizeArguments(url, opts), cb);
return null;
}
try {
return asPromise(normalizeArguments(url, opts));
} catch (err) {
return PinkiePromise.reject(err);
}
}
module.exports = function (patterns, opts) {
var globTasks;
try {
globTasks = generateGlobTasks(patterns, opts);
} catch (err) {
return Promise.reject(err);
}
return Promise.all(globTasks.map(function (task) {
return globP(task.pattern, task.opts);
})).then(function (paths) {
return arrayUnion.apply(null, paths);
});
};
exports.set = function (val) {
if (process.platform !== 'darwin') {
return Promise.reject(new Error('Only OS X systems are supported'));
}
if (typeof val !== 'number' || isNaN(val)) {
return Promise.reject(new TypeError('Expected a number'));
}
if (!inRange(val, 1)) {
return Promise.reject(new Error('Expected a value between 0 and 1'));
}
return pify(execFile, Promise)('./main', [val], {cwd: __dirname});
};
.catch(function () {
var message = format('Feature `%s` does not exist', name);
return Promise.reject(message);
});
};
module.exports = function (target, opts) {
if (typeof target !== 'string') {
return Promise.reject(new Error('Expected a `target`'));
}
opts = objectAssign({wait: true}, opts);
var cmd;
var appArgs = [];
var args = [];
var cpOpts = {};
if (Array.isArray(opts.app)) {
appArgs = opts.app.slice(1);
opts.app = opts.app[0];
}
if (process.platform === 'darwin') {
cmd = 'open';
module.exports = function (paths) {
if (process.platform !== 'linux') {
return Promise.reject(new Error('Only Linux systems are supported'));
}
if (!Array.isArray(paths)) {
return Promise.reject(new TypeError('Expected an array'));
}
if (paths.length === 0) {
return Promise.resolve();
}
return Promise.all(paths.map(function (p) {
return trash(path.resolve(String(p)));
}));
};
module.exports = function (paths) {
if (process.platform !== 'linux') {
return Promise.reject(new Error('Only Linux systems are supported'));
}
if (!Array.isArray(paths)) {
return Promise.reject(new TypeError('Expected an array'));
}
if (paths.length === 0) {
return Promise.resolve();
}
return Promise.all(paths.map(function (p) {
return trash(path.resolve(String(p)));
}));
};
function type(fn, fn2, fp) {
if (typeof fp !== 'string') {
return Promise.reject(new TypeError('Expected a string'));
}
return pify(fs[fn], Promise)(fp).then(function (stats) {
return stats[fn2]();
});
}