forked from anomalyco/sst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-cdk.js
More file actions
31 lines (22 loc) · 804 Bytes
/
Copy pathadd-cdk.js
File metadata and controls
31 lines (22 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
const chalk = require("chalk");
const spawn = require("cross-spawn");
const { logger } = require("@serverless-stack/core");
module.exports = async function (argv, config, cliInfo) {
const npm = cliInfo.npm;
const dryRun = argv.dryRun;
const cdkVersion = cliInfo.cdkVersion;
const packages = argv.packages.map((pkg) => `${pkg}@${cdkVersion}`);
const command = npm ? "npm" : "yarn";
const helperCopy = dryRun ? "Dry run" : "Running";
let args = npm ? ["install", "--save-exact"] : ["add", "--exact"];
if (argv.dev) {
args = args.concat(npm ? "--save-dev" : "--dev");
}
args = args.concat(packages);
logger.info(chalk.grey(`${helperCopy}: ${command} ${args.join(" ")}`));
if (dryRun) {
return;
}
spawn.sync(command, args, { stdio: "inherit" });
};