Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(function (resolve, reject) {
if (!value) {
reject(new errors.ArgumentNullError('value'));
return;
}
['dir'].forEach(function (key) {
if(!value.hasOwnProperty(key) || !value[key]) {
reject(new errors.ArgumentNullError(key));
return;
}
});
var targetDir = removeTrailingSlash(path.normalize(value['dir']));
if (targetDir.split(path.sep).indexOf('..') !== -1) {
reject(new errors.ArgumentError('dir has .. directory'));
return;
}
tmp.setGracefulCleanup();
return new Promise(function (resolve, reject) {
if (!value) {
reject(new errors.ArgumentNullError('value'));
return;
}
['input', 'packageName'].forEach(function (key) {
if(!value.hasOwnProperty(key) || !value[key]) {
reject(new errors.ArgumentNullError(key));
return;
}
});
var packageName = value['packageName'];
var input = removeTrailingSeparator(value['input']);
if (!isPackage(packageName)) {
reject(new errors.ArgumentError(packageName + 'is not package'));
return;
}
var split = path.normalize(input).split(path.sep);
var inputLast = split[split.length - 1];
['input', 'packageName'].forEach(function (key) {
if(!value.hasOwnProperty(key) || !value[key]) {
reject(new errors.ArgumentNullError(key));
return;
}
});
var packageName = value['packageName'];
return new Promise(function (resolve, reject) {
if (!value) {
reject(new errors.ArgumentNullError('value'));
return;
}
if(!value.hasOwnProperty('data') || !value['data']) {
reject(new errors.ArgumentNullError('data'));
return;
}
if(!value.hasOwnProperty('field') || !value['field']) {
reject(new errors.ArgumentNullError('field'));
return;
}
resolve(value['data'][value['field']]);
});
};
return new Promise(function (resolve, reject) {
if (!value) {
reject(new errors.ArgumentNullError('value'));
return;
}
if(!value.hasOwnProperty('data') || !value['data']) {
reject(new errors.ArgumentNullError('data'));
return;
}
if(!value.hasOwnProperty('field') || !value['field']) {
reject(new errors.ArgumentNullError('field'));
return;
}
resolve(value['data'][value['field']]);
});
};
['dir'].forEach(function (key) {
if(!value.hasOwnProperty(key) || !value[key]) {
reject(new errors.ArgumentNullError(key));
return;
}
});
return new Promise(function (resolve, reject) {
if (!value) {
reject(new errors.ArgumentNullError('value'));
return;
}
if(!value.hasOwnProperty('data') || !value['data']) {
reject(new errors.ArgumentNullError('data'));
return;
}
if(!value.hasOwnProperty('field') || !value['field']) {
reject(new errors.ArgumentNullError('field'));
return;
}
resolve(value['data'][value['field']]);
});
};
return new Promise(function(resolve, reject) {
if (!value) {
reject(new errors.ArgumentNullError('value'));
return;
}
if(!value.hasOwnProperty('path') || !value['path']) {
reject(new errors.ArgumentNullError('path'));
return;
}
var filePath = path.normalize(value['path']);
fs.readFile(filePath, 'utf8', function (err, data) {
if (err) {
reject(new errors.io.FileLoadError(filePath));
return;
}
try {
var contents = JSON.parse(data);
} catch (error) {
reject(new errors.Error('JSON.parse', error));
return;
}
resolve(contents);
return new Promise(function(resolve, reject) {
if (!value) {
reject(new errors.ArgumentNullError('value'));
return;
}
if(!value.hasOwnProperty('path') || !value['path']) {
reject(new errors.ArgumentNullError('path'));
return;
}
var filePath = path.normalize(value['path']);
fs.readFile(filePath, 'utf8', function (err, data) {
if (err) {
reject(new errors.io.FileLoadError(filePath));
return;
}
try {
var contents = JSON.parse(data);
} catch (error) {