| Server IP : 82.148.16.210 / Your IP : 216.73.216.249 Web Server : nginx/1.29.5 System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/pkg-conf/ |
Upload File : |
'use strict';
const path = require('path');
const findUp = require('find-up');
const loadJsonFile = require('load-json-file');
const filepaths = new WeakMap();
const filepath = conf => filepaths.get(conf);
const findNextCwd = pkgPath => path.resolve(path.dirname(pkgPath), '..');
const addFp = (obj, fp) => {
filepaths.set(obj, fp);
return obj;
};
const pkgConf = (namespace, opts) => {
if (!namespace) {
return Promise.reject(new TypeError('Expected a namespace'));
}
opts = opts || {};
return findUp('package.json', opts.cwd ? {cwd: opts.cwd} : {})
.then(fp => {
if (!fp) {
return addFp(Object.assign({}, opts.defaults), fp);
}
return loadJsonFile(fp).then(pkg => {
if (opts.skipOnFalse && pkg[namespace] === false) {
const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)});
return pkgConf(namespace, newOpts);
}
return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp);
});
});
};
const sync = (namespace, opts) => {
if (!namespace) {
throw new TypeError('Expected a namespace');
}
opts = opts || {};
const fp = findUp.sync('package.json', opts.cwd ? {cwd: opts.cwd} : {});
if (!fp) {
return addFp(Object.assign({}, opts.defaults), fp);
}
const pkg = loadJsonFile.sync(fp);
if (opts.skipOnFalse && pkg[namespace] === false) {
const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)});
return sync(namespace, newOpts);
}
return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp);
};
module.exports = pkgConf;
module.exports.filepath = filepath;
module.exports.sync = sync;