Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.sync = (fp, opts) => {
if (typeof fp !== 'string') {
opts = fp;
fp = '.';
}
opts = opts || {};
fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
const x = loadJsonFile.sync(fp);
if (opts.normalize !== false) {
require('normalize-package-data')(x);
}
return x;
};
const assertIgnored = (filepath) => {
const failMessage = `File must be ignored by git. Fix: echo '${path.basename(filepath)}' >> .gitignore`;
let ignores;
try {
ignores = fs.readFileSync(path.join(filepath, '..', '.gitignore'), 'utf8');
}
catch (error) {
if (error.code === 'ENOENT') {
if (!pathType.dirSync(path.join(filepath, '..', '.git'))) {
return;
}
throw new Error(failMessage);
}
throw error;
}
if (!ignores.split(/\r?\n/u).includes(path.basename(filepath))) {
throw new Error(failMessage);
}
};
function isExistingDirectory(value: *): boolean {
if (!_.isString(value)) {
return false;
}
return pathType.dirSync(value);
}
module.exports.sync = function (fp, opts) {
if (typeof fp !== 'string') {
opts = fp;
fp = '.';
}
opts = opts || {};
fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
var x = loadJsonFile.sync(fp);
if (opts.normalize !== false) {
normalizePackageData(x);
}
return x;
};
module.exports.sync = (fp, opts) => {
if (typeof fp !== 'string') {
opts = fp;
fp = '.';
}
opts = opts || {};
fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
const x = loadJsonFile.sync(fp);
if (opts.normalize !== false) {
require('normalize-package-data')(x);
}
return x;
};
module.exports.sync = function (fp, opts) {
if (typeof fp !== 'string') {
opts = fp;
fp = '.';
}
opts = opts || {};
fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
var x = loadJsonFile.sync(fp);
if (opts.normalize !== false) {
normalizePackageData(x);
}
return x;
};