123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.install = install;
- var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
- var _crossSpawn = _interopRequireDefault(require("next/dist/compiled/cross-spawn"));
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {
- default: obj
- };
- }
- function install(root, dependencies, { packageManager , isOnline , devDependencies }) {
-
- const npmFlags = [];
-
- const yarnFlags = [];
-
- return new Promise((resolve, reject)=>{
- let args;
- let command = packageManager;
- const useYarn = packageManager === "yarn";
- if (dependencies && dependencies.length) {
-
- if (useYarn) {
-
- args = [
- "add",
- "--exact"
- ];
- if (!isOnline) args.push("--offline");
- args.push("--cwd", root);
- if (devDependencies) args.push("--dev");
- args.push(...dependencies);
- } else {
-
- args = [
- "install",
- "--save-exact"
- ];
- args.push(devDependencies ? "--save-dev" : "--save");
- args.push(...dependencies);
- }
- } else {
-
- args = [
- "install"
- ];
- if (!isOnline) {
- console.log(_chalk.default.yellow("You appear to be offline."));
- if (useYarn) {
- console.log(_chalk.default.yellow("Falling back to the local Yarn cache."));
- console.log();
- args.push("--offline");
- } else {
- console.log();
- }
- }
- }
-
- if (useYarn) {
- args.push(...yarnFlags);
- } else {
- args.push(...npmFlags);
- }
-
- const child = (0, _crossSpawn).default(command, args, {
- stdio: "inherit",
- env: {
- ...process.env,
- ADBLOCK: "1",
-
-
- NODE_ENV: "development",
- DISABLE_OPENCOLLECTIVE: "1"
- }
- });
- child.on("close", (code)=>{
- if (code !== 0) {
- reject({
- command: `${command} ${args.join(" ")}`
- });
- return;
- }
- resolve();
- });
- });
- }
|