pnpm
Version:
A fast implementation of npm install
29 lines • 1.01 kB
JavaScript
;
const mkdirp = require('mkdirp');
const fs = require('fs');
const path = require('path');
const common_tags_1 = require('common-tags');
const globalPath_1 = require('./globalPath');
const root = process.cwd();
process.env.ROOT = root;
const tmpPath = path.join(root, '.tmp');
mkdirp.sync(tmpPath);
const npmrc = common_tags_1.stripIndent `
store-path = ./node_modules/.store
fetch-retries = 5
fetch-retry-maxtimeout = 180000
registry = http://localhost:4873/
quiet = true
global-path = ${globalPath_1.default}
`;
fs.writeFileSync(path.join(tmpPath, '.npmrc'), npmrc, 'utf-8');
function prepare(pkg) {
const pkgTmpPath = path.join(tmpPath, Number(new Date()).toString());
mkdirp.sync(pkgTmpPath);
const json = JSON.stringify(pkg || {});
fs.writeFileSync(path.join(pkgTmpPath, 'package.json'), json, 'utf-8');
process.chdir(pkgTmpPath);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = prepare;
//# sourceMappingURL=prepare.js.map