UNPKG

852 BJavaScriptView Raw
1import Promise from "bluebird";
2import shell from "shelljs";
3import { shellAsync } from "./util";
4
5const WORKING_DIRECTORY = process.cwd();
6
7
8
9/**
10 * Runs `npm install` on the app.
11 * @param localFolder: The path to where the app it stored on the local disk.
12 * @return {Promise}.
13 */
14export default (localFolder) => {
15 return new Promise((resolve, reject) => {
16 shell.cd(localFolder);
17 shellAsync("npm install --loglevel error >&-")
18 .then(result => {
19 shell.cd(WORKING_DIRECTORY);
20 if (result.code === 0) {
21 resolve(result);
22 } else {
23 result.error = `Failed while running 'npm install'.`;
24 reject(result);
25 }
26 })
27 .catch(err => reject(err))
28 .finally(() => shell.cd(WORKING_DIRECTORY));
29 });
30
31};