waka-pm
Version:
a pnpm supplement for enforcing consistent versions across all workspaces
75 lines • 2.92 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExternalConfig = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const configName = 'waka.config.js';
const configTemplate = {
installPreEvaluate: async (_args) => {
// pre install
},
installPreWrite: async (_args) => {
// install pre write
},
installPostWrite: async (_args) => {
// install post write
},
applyPreEvaluate: async (_args) => {
// apply pre evaluate
},
applyPreWrite: async (_args) => {
// apply pre write
},
applyPostWrite: async (_args) => {
// apply post write
},
};
async function getExternalConfig(rootDir, opts) {
if (opts?.configPath) {
if (fs_1.default.existsSync(opts.configPath)) {
const config = (await Promise.resolve(`${opts.configPath}`).then(s => __importStar(require(s))));
return { ...configTemplate, ...config };
}
else {
const configPath = path_1.default.join(opts.configPath, configName);
if (fs_1.default.existsSync(configPath)) {
const config = (await Promise.resolve(`${configPath}`).then(s => __importStar(require(s))));
return { ...configTemplate, ...config };
}
}
}
const configPath = path_1.default.join(rootDir, configName);
if (fs_1.default.existsSync(configPath)) {
const config = (await Promise.resolve(`${configPath}`).then(s => __importStar(require(s))));
return { ...configTemplate, ...config };
}
return configTemplate;
}
exports.getExternalConfig = getExternalConfig;
//# sourceMappingURL=ext-config.js.map