@lerna/publish
Version:
Publish packages in the current project
64 lines (63 loc) • 2.62 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_path = __toESM(require("path"));
var import_conf = require("./conf");
var import_nerf_dart = require("./nerf-dart");
const { defaults } = require("./defaults");
module.exports = npmConf;
module.exports.Conf = import_conf.Conf;
module.exports.defaults = Object.assign({}, defaults);
module.exports.toNerfDart = import_nerf_dart.toNerfDart;
function npmConf(opts) {
const conf = new import_conf.Conf(Object.assign({}, defaults));
const cleanOpts = opts ? Object.keys(opts).reduce((acc, key) => {
if (opts[key] !== void 0) {
acc[key] = opts[key];
}
return acc;
}, {}) : {};
conf.add(cleanOpts, "cli");
conf.addEnv();
conf.loadPrefix();
const projectConf = import_path.default.resolve(conf["localPrefix"], ".npmrc");
const userConf = conf["get"]("userconfig");
if (!conf["get"]("global") && projectConf !== userConf) {
conf.addFile(projectConf, "project");
} else {
conf.add({}, "project");
}
conf.addFile(conf["get"]("userconfig"), "user");
if (conf["get"]("prefix")) {
const etc = import_path.default.resolve(conf["get"]("prefix"), "etc");
conf.root.globalconfig = import_path.default.resolve(etc, "npmrc");
conf.root.globalignorefile = import_path.default.resolve(etc, "npmignore");
}
conf.addFile(conf["get"]("globalconfig"), "global");
conf.loadUser();
const caFile = conf["get"]("cafile");
if (caFile) {
conf.loadCAFile(caFile);
}
return conf;
}