1 | import Promise from "bluebird";
|
2 | import shell from "shelljs";
|
3 | import { shellAsync } from "./util";
|
4 |
|
5 | const WORKING_DIRECTORY = process.cwd();
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export 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 | };
|