secrez 2.1.15 → 2.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,40 +1,37 @@
1
1
  {
2
2
  "name": "secrez",
3
- "version": "2.1.15",
3
+ "version": "2.2.0-beta.1",
4
4
  "license": "MIT",
5
5
  "nyc": {
6
6
  "include": "src",
7
7
  "exclude": []
8
8
  },
9
9
  "dependencies": {
10
- "@secrez/core": "~1.0.6",
11
- "@secrez/crypto": "~1.0.5",
12
- "@secrez/eth": "~0.0.5",
13
- "@secrez/fs": "~1.0.8",
14
- "@secrez/utils": "~1.0.5",
10
+ "@secrez/core": "~1.1.0",
11
+ "@secrez/crypto": "~1.1.0",
12
+ "@secrez/eth": "~0.0.6",
13
+ "@secrez/fs": "~1.1.0",
14
+ "@secrez/utils": "~1.1.0",
15
15
  "case": "^1.6.3",
16
16
  "chalk": "^3.0.0",
17
17
  "clipboardy": "^2.3.0",
18
18
  "command-line-args": "^5.2.1",
19
- "external-editor": "^3.1.0",
19
+ "ansi-escapes": "^4.3.2",
20
20
  "fs-extra": "^9.1.0",
21
- "homedir": "^0.6.0",
22
21
  "inquirer": "^7.3.3",
23
22
  "inquirer-command-prompt": "^0.1.0",
24
- "jimp": "^0.13.0",
23
+ "jimp": "^1.6.0",
24
+ "jsqr": "^1.4.0",
25
25
  "lodash": "^4.17.21",
26
26
  "otplib": "^12.0.1",
27
- "qrcode": "^1.5.4",
28
- "qrcode-reader": "^1.0.4",
29
- "tiny-cli-editor": "^0.1.1"
27
+ "qrcode": "^1.5.4"
30
28
  },
31
29
  "devDependencies": {
32
- "@secrez/test-helpers": "~2.0.1",
30
+ "@secrez/test-helpers": "~2.0.3",
33
31
  "chai": "^4.5.0",
34
32
  "chalk": "^3.0.0",
35
33
  "cross-env": "^7.0.3",
36
- "dotenv": "^17.2.2",
37
- "mocha": "^7.2.0",
34
+ "mocha": "^10.8.2",
38
35
  "nyc": "^15.1.0",
39
36
  "test-console": "^1.1.0"
40
37
  },
@@ -57,14 +54,14 @@
57
54
  },
58
55
  "homepage": "https://github.com/secrez/secrez#readme",
59
56
  "engines": {
60
- "node": ">=10.0.0"
57
+ "node": ">=20.0.0"
61
58
  },
62
59
  "gitHead": "42cbc519dd2802a1e03c6203bb724c726c2bfb79",
63
60
  "scripts": {
64
61
  "dev": "cross-env NODE_ENV=dev bin/secrez.js -c `pwd`/tmp/secrez-dev -i 1e3 -l `pwd`/tmp",
65
62
  "test-only": "cross-env NODE_ENV=test ./node_modules/.bin/mocha test/*.test.js test/**/*.test.js test/**/**/*.js --exit",
66
63
  "test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.test.js test/**/*.test.js test/**/**/*.js --exit",
67
- "posttest": "nyc check-coverage --statements 65 --branches 50 --functions 65 --lines 65",
64
+ "posttest": "nyc check-coverage --statements 85 --branches 73 --functions 85 --lines 85",
68
65
  "build-helpers": "cd test/helpers/os && ./build.sh",
69
66
  "preinstall": "node scripts/preinstall.js"
70
67
  }
package/src/PreCommand.js CHANGED
@@ -1,36 +1,25 @@
1
1
  const { chalk } = require("./utils/Logger");
2
2
  const Crypto = require("@secrez/crypto");
3
+ const { editInMemory } = require("./editor/MemoryEditor");
3
4
 
4
5
  class PreCommand {
5
6
  async useEditor(options) {
6
- let message = "your OS default editor.";
7
- if (options.internal) {
8
- message = "the minimalistic internal editor.";
9
- } else if (options.editor) {
10
- message = `${options.editor}.`;
7
+ if (this.prompt.editorProvider) {
8
+ return this.prompt.editorProvider(options);
9
+ } /* istanbul ignore next */ else {
10
+ const rl = this.prompt.getRl && this.prompt.getRl();
11
+ if (rl) {
12
+ rl.pause();
13
+ }
14
+
15
+ try {
16
+ return await editInMemory(options.content || "");
17
+ } finally {
18
+ if (rl) {
19
+ rl.resume();
20
+ }
21
+ }
11
22
  }
12
- let extraMessage =
13
- chalk.dim("Press <enter> to launch ") +
14
- message +
15
- chalk.reset(
16
- options.internal
17
- ? chalk.green("\n Ctrl-d to save the changes. Ctrl-c to abort.")
18
- : ""
19
- );
20
- let { result } = await this.prompt.inquirer.prompt([
21
- {
22
- type: "multiEditor",
23
- name: "result",
24
- message: "Editing...",
25
- default: options.content,
26
- tempDir: this.cliConfig.tmpPath,
27
- validate: function (text) {
28
- return true;
29
- },
30
- extraMessage,
31
- },
32
- ]);
33
- return result;
34
23
  }
35
24
 
36
25
  async useSelect(options) {
package/src/Welcome.js CHANGED
@@ -4,6 +4,8 @@ const fs = require("fs-extra");
4
4
  const Crypto = require("@secrez/crypto");
5
5
  const Logger = require("./utils/Logger");
6
6
 
7
+ const LOW_ITERATIONS_WARNING_THRESHOLD = 100000;
8
+
7
9
  class Welcome {
8
10
  async start(secrez, options) {
9
11
  this.secrez = secrez;
@@ -65,6 +67,31 @@ Thanks.`);
65
67
  return parseInt(iterations);
66
68
  }
67
69
 
70
+ async confirmLowIterations(iterations) {
71
+ if (iterations >= LOW_ITERATIONS_WARNING_THRESHOLD) {
72
+ return true;
73
+ }
74
+ Logger.yellow(
75
+ chalk.bold(`
76
+ Warning: you chose fewer than ${LOW_ITERATIONS_WARNING_THRESHOLD.toLocaleString()} iterations.
77
+ `)
78
+ );
79
+ Logger.yellow(
80
+ `Secrez does not salt the KDF with the password alone: the iteration count is mixed into the salt, which makes offline attacks significantly slower than with a typical password-only salt.
81
+
82
+ We recommend 500,000–1,000,000 iterations for most setups. A random per-account salt is planned for a future release.`
83
+ );
84
+ const { proceed } = await inquirer.prompt([
85
+ {
86
+ name: "proceed",
87
+ type: "confirm",
88
+ message: "Continue signup with this iteration count?",
89
+ default: false,
90
+ },
91
+ ]);
92
+ return proceed;
93
+ }
94
+
68
95
  // chimney piano fabric forest curious black hip axis story stool spoil fold
69
96
  async saveIterations() {
70
97
  if (this.options.saveIterations) {
@@ -96,9 +123,6 @@ Thanks.`);
96
123
  }
97
124
  return 0;
98
125
  } catch (e) {
99
- if (e.message === "A second factor is required") {
100
- return 1;
101
- }
102
126
  Logger.red(`${e.message}.Try again or Ctrl - C to exit.`);
103
127
  }
104
128
  } catch (e) {
@@ -110,6 +134,11 @@ Thanks.`);
110
134
  async signup() {
111
135
  for (;;) {
112
136
  try {
137
+ if (!(await this.confirmLowIterations(this.iterations))) {
138
+ delete this.options.iterations;
139
+ this.iterations = await this.getIterations();
140
+ continue;
141
+ }
113
142
  let p = await inquirer.prompt([
114
143
  {
115
144
  name: "password",
@@ -155,4 +184,7 @@ Thanks.`);
155
184
  }
156
185
  }
157
186
 
158
- module.exports = new Welcome();
187
+ const welcome = new Welcome();
188
+ welcome.LOW_ITERATIONS_WARNING_THRESHOLD = LOW_ITERATIONS_WARNING_THRESHOLD;
189
+
190
+ module.exports = welcome;
@@ -43,16 +43,6 @@ class Conf extends require("../Command") {
43
43
  };
44
44
  }
45
45
 
46
- async getAllFactors() {
47
- let allFactors = {};
48
- const conf = this.secrez.getConf();
49
- let keys = conf.data.keys || {};
50
- for (let authenticator in keys) {
51
- allFactors[authenticator] = keys[authenticator].type;
52
- }
53
- return allFactors;
54
- }
55
-
56
46
  async showConf(options) {
57
47
  const env = await ConfigUtils.getEnv(this.secrez.config);
58
48
  this.Logger.reset(chalk.grey("Container: ") + this.secrez.config.container);
@@ -86,10 +76,6 @@ class Conf extends require("../Command") {
86
76
  "Changing password and number of iterations in the same operation not allowed"
87
77
  );
88
78
  }
89
- let haveSomeFactors = false;
90
- if (Object.keys(await this.getAllFactors()).length) {
91
- haveSomeFactors = true;
92
- }
93
79
  let message =
94
80
  "Are you sure you want to upgrade your " +
95
81
  (pw ? "password" : "number of iterations") +
@@ -140,11 +126,6 @@ class Conf extends require("../Command") {
140
126
  this.Logger.reset(
141
127
  'In case you have doubts about it, please, "cat" the file and take a look before exiting.'
142
128
  );
143
- if (haveSomeFactors) {
144
- this.Logger.yellow(
145
- "All the second factors have been unregistered."
146
- );
147
- }
148
129
  return;
149
130
  }
150
131
  }
@@ -5,6 +5,18 @@ const { isYaml, yamlParse, TRUE, sleep, playMp3 } = require("@secrez/utils");
5
5
  const { Node } = require("@secrez/fs");
6
6
  const { execSync } = require("child_process");
7
7
 
8
+ let clipboardQueue = Promise.resolve();
9
+
10
+ function runClipboardTask(task) {
11
+ const next = clipboardQueue.then(task, task);
12
+ clipboardQueue = next.catch(() => {});
13
+ return next;
14
+ }
15
+
16
+ async function drainClipboardQueue() {
17
+ await clipboardQueue;
18
+ }
19
+
8
20
  class Copy extends require("../Command") {
9
21
  setHelpAndCompletion() {
10
22
  this.cliConfig.completion.copy = {
@@ -1,17 +1,6 @@
1
- // Next line is to avoid that npm-check-unused reports it
2
- require("tiny-cli-editor");
3
- //
4
-
5
1
  const _ = require("lodash");
6
- const path = require("path");
7
- const fs = require("fs-extra");
8
2
  const { Entry } = require("@secrez/core");
9
- const {
10
- isYaml,
11
- yamlParse,
12
- yamlStringify,
13
- execAsync,
14
- } = require("@secrez/utils");
3
+ const { isYaml, yamlParse, yamlStringify } = require("@secrez/utils");
15
4
 
16
5
  class Edit extends require("../Command") {
17
6
  setHelpAndCompletion() {
@@ -33,16 +22,6 @@ class Edit extends require("../Command") {
33
22
  defaultOption: true,
34
23
  type: String,
35
24
  },
36
- {
37
- name: "editor",
38
- alias: "e",
39
- type: String,
40
- },
41
- {
42
- name: "internal",
43
- alias: "i",
44
- type: Boolean,
45
- },
46
25
  {
47
26
  name: "field",
48
27
  alias: "f",
@@ -60,46 +39,45 @@ class Edit extends require("../Command") {
60
39
  help() {
61
40
  return {
62
41
  description: [
63
- "Edits a file containing a secret.",
64
- "If no default editor is installed, you can use the minimalistic internal editor.",
65
- "It supports only two commands:",
66
- "" + " Ctrl-c to cancel",
42
+ "Edits a file containing a secret using the in-memory editor.",
43
+ "Secrets are never written to a temporary file on disk.",
44
+ "Editor commands:",
45
+ " Ctrl-c to cancel",
67
46
  " Ctrl-d to save",
68
- "WARNING: Do not quit forcely because a temp file can remain on disk, unencrypted. If for any reason you do it, launch Secrez again because at start it empties the temp folder.",
47
+ " Ctrl-k to delete the current line",
69
48
  ],
70
49
  examples: [
71
- ["edit ../coins/ether2-pwd", "uses the OS default editor"],
72
- ["edit ../bitcoin/seed -i", "uses the minimalistic internal editor"],
73
- [
74
- "edit ../bitcoin/seed -e nano",
75
- "choses the editor, in this case nano",
76
- ],
77
- ["edit ../bitcoin/seed -e vim", "uses vim"],
50
+ ["edit ../coins/ether2-pwd", "edits a secret file"],
78
51
  [
79
52
  "edit gmail.yml -f password",
80
53
  "edits only the field password of the yaml file. If the field does not exist, a new field is added",
81
54
  ],
55
+ [
56
+ "edit main:/gmail.yml -f password",
57
+ "edits a file using a dataset-qualified path",
58
+ ],
82
59
  ["edit damaged.yaml -u", "edits damaged.yaml without parsing it"],
83
60
  ],
84
61
  };
85
62
  }
86
63
 
87
64
  async edit(options) {
88
- let file = options.path;
89
- if (/:/.test(file)) {
90
- // TODO Fix this
91
- throw new Error(
92
- "Edit works only on the current dataset. Remove the dataset from the path, please"
93
- );
94
- }
95
- let sanitizedPath = Entry.sanitizePath(options.path);
96
- if (sanitizedPath !== options.path) {
65
+ let data = await this.internalFs.getTreeIndexAndPath(options.path);
66
+ let file = data.path;
67
+ let tree = data.tree;
68
+
69
+ let sanitizedPath = Entry.sanitizePath(file);
70
+ if (sanitizedPath !== file) {
97
71
  throw new Error("A filename cannot contain \\/><|:&?*^$ chars.");
98
72
  }
73
+
99
74
  let exists = false;
100
75
  let fileData;
101
76
  try {
102
- fileData = await this.prompt.commands.cat.cat({ path: file }, true);
77
+ fileData = await this.prompt.commands.cat.cat(
78
+ { path: options.path },
79
+ true
80
+ );
103
81
  exists = true;
104
82
  } catch (e) {
105
83
  if (options.field) {
@@ -108,8 +86,9 @@ class Edit extends require("../Command") {
108
86
  fileData = [{ content: "" }];
109
87
  }
110
88
 
89
+ let p = tree.getNormalizedPath(file);
111
90
  let fields = {};
112
- if (exists && !options.unformatted && isYaml(file)) {
91
+ if (exists && !options.unformatted && isYaml(p)) {
113
92
  fields = fileData[0].content ? yamlParse(fileData[0].content) : {};
114
93
  if (typeof fields === "object") {
115
94
  options.choices = Object.keys(fields);
@@ -124,7 +103,7 @@ class Edit extends require("../Command") {
124
103
  } else {
125
104
  delete options.field;
126
105
  }
127
- } else if (!isYaml(file)) {
106
+ } else if (!isYaml(p)) {
128
107
  delete options.field;
129
108
  }
130
109
  let content = options.field
@@ -134,18 +113,18 @@ class Edit extends require("../Command") {
134
113
 
135
114
  if (newContent && newContent !== content) {
136
115
  if (exists) {
137
- let node = this.internalFs.tree.workingNode.getChildFromPath(file);
116
+ let node = tree.root.getChildFromPath(p);
138
117
  let entry = node.getEntry();
139
118
  if (options.field) {
140
119
  fields[options.field] = _.trim(newContent);
141
- entry.content = yamlStringify(fields);
120
+ entry.set({ content: yamlStringify(fields) });
142
121
  } else {
143
- entry.content = newContent;
122
+ entry.set({ content: newContent });
144
123
  }
145
- await this.internalFs.tree.update(node, entry);
124
+ await tree.update(node, entry);
146
125
  } else {
147
126
  await this.prompt.commands.touch.touch({
148
- path: file,
127
+ path: options.path,
149
128
  content: newContent,
150
129
  });
151
130
  }
@@ -155,70 +134,24 @@ class Edit extends require("../Command") {
155
134
  }
156
135
  }
157
136
 
158
- getTinyCliEditorBinPath() {
159
- if (!this.editorBinPath) {
160
- let bin = path.resolve(
161
- __dirname,
162
- "../../node_modules/tiny-cli-editor/bin.js"
163
- );
164
- if (!fs.existsSync(bin)) {
165
- bin = path.resolve(
166
- __dirname,
167
- "../../../../node_modules/tiny-cli-editor/bin.js"
168
- );
169
- }
170
- if (!fs.existsSync(bin)) {
171
- throw new Error("Default editor not found");
172
- }
173
- this.editorBinPath = bin;
174
- }
175
- return this.editorBinPath;
176
- }
177
-
178
137
  async exec(options = {}) {
179
138
  if (options.help) {
180
139
  return this.showHelp();
181
140
  }
182
- let currentEditor;
183
141
  try {
184
142
  this.validate(options, {
185
143
  path: true,
186
144
  });
187
145
 
188
- if (!options.help) {
189
- // Check for git conflicts before editing files (edit always changes something)
190
- const shouldProceed = await this.checkGitConflictsBeforeOperation();
191
- if (!shouldProceed) {
192
- return;
193
- }
194
- }
195
- currentEditor = process.env.EDITOR;
196
- if (options.internal) {
197
- process.env.EDITOR = this.getTinyCliEditorBinPath();
198
- } else if (options.editor) {
199
- process.env.EDITOR = options.editor;
200
- }
201
- if (!process.env.EDITOR) {
202
- let result = await execAsync("which", __dirname, ["nano"]);
203
- if (!result.message || result.code === 1) {
204
- result = await execAsync("which", __dirname, ["vim"]);
205
- if (!result.message || result.code === 1) {
206
- throw new Error(
207
- 'No text editor found. Set up the EDITOR env variable or use the -e option. Type "edit -h" for more options.'
208
- );
209
- } else {
210
- process.env.EDITOR = "vim";
211
- }
212
- } else {
213
- process.env.EDITOR = "nano";
214
- }
146
+ const shouldProceed = await this.checkGitConflictsBeforeOperation();
147
+ if (!shouldProceed) {
148
+ return;
215
149
  }
150
+
216
151
  await this.edit(options);
217
152
  } catch (e) {
218
153
  this.Logger.red(e.message);
219
154
  }
220
- // eslint-disable-next-line require-atomic-updates
221
- process.env.EDITOR = currentEditor;
222
155
  await this.prompt.run();
223
156
  }
224
157
  }
@@ -57,6 +57,11 @@ class Export extends require("../Command") {
57
57
  name: "password",
58
58
  type: String,
59
59
  },
60
+ {
61
+ name: "iterations",
62
+ alias: "i",
63
+ type: Number,
64
+ },
60
65
  {
61
66
  name: "include-me",
62
67
  type: Boolean,
@@ -96,8 +101,8 @@ class Export extends require("../Command") {
96
101
  'asks for a password and encrypts seed.json before exporting it. The final file will have the extension ".secrez"',
97
102
  ],
98
103
  [
99
- 'export seed.json -e --password "some strong password"',
100
- "uses the typed password to encrypt seed.json before exporting it",
104
+ 'export seed.json -e --password "some strong password" -i 500000',
105
+ "uses the typed password and iterations to encrypt seed.json before exporting it",
101
106
  ],
102
107
  [
103
108
  "export seed.json -ec bob alice",
@@ -260,6 +265,23 @@ class Export extends require("../Command") {
260
265
  throw new Error("The two password do not match");
261
266
  }
262
267
  options.password = pwd;
268
+ if (!options.iterations) {
269
+ let iterationsInput = await this.useInput({
270
+ message:
271
+ "Type the number of iterations for encrypting this export",
272
+ validate: (val) => {
273
+ const n = parseInt(val, 10);
274
+ return (
275
+ (n > 0 && String(n) === String(val).trim()) ||
276
+ "Must be a positive integer"
277
+ );
278
+ },
279
+ });
280
+ if (!iterationsInput) {
281
+ throw new Error("Operation canceled");
282
+ }
283
+ options.iterations = parseInt(iterationsInput, 10);
284
+ }
263
285
  }
264
286
  content = fileCipher.encryptFile(content, options).join(",");
265
287
  }
@@ -50,7 +50,7 @@ class Find extends require("../Command") {
50
50
  name: "global",
51
51
  alias: "g",
52
52
  type: Boolean,
53
- hint: "Search in all the datasets",
53
+ hint: "Search in all datasets from root",
54
54
  },
55
55
  {
56
56
  name: "trash-too",
@@ -104,6 +104,10 @@ class Find extends require("../Command") {
104
104
  }
105
105
 
106
106
  async find(options) {
107
+ if (options.global) {
108
+ options.root = true;
109
+ }
110
+
107
111
  // Handle recent mode
108
112
  if (options.recent) {
109
113
  // Set default limit if not specified by user
@@ -76,6 +76,11 @@ class Import extends require("../Command") {
76
76
  name: "password",
77
77
  type: String,
78
78
  },
79
+ {
80
+ name: "iterations",
81
+ alias: "i",
82
+ type: Number,
83
+ },
79
84
  {
80
85
  name: "public-key",
81
86
  type: String,
@@ -101,8 +106,12 @@ class Import extends require("../Command") {
101
106
  "copies seed.json from the disk into the current directory",
102
107
  ],
103
108
  [
104
- "import seed.json.secrez --password s8eeuhwy36534",
105
- "imports seed.json and decrypts it using the specified password",
109
+ "import seed.json.secrez --password s8eeuhwy36534 -i 500000",
110
+ "imports seed.json and decrypts it using the specified password and iterations",
111
+ ],
112
+ [
113
+ "import old-backup.secrez --password s8eeuhwy36534",
114
+ "imports a file encrypted with the legacy v1 format (password only; no iterations)",
106
115
  ],
107
116
  [
108
117
  "import seed.json.secrez",
@@ -247,6 +256,24 @@ class Import extends require("../Command") {
247
256
  if (!options.contactPublicKey) {
248
257
  options.contactsPublicKeys = contactsPublicKeys;
249
258
  }
259
+ const version = String(c[2]).split(",")[0];
260
+ if (version === "2" && options.password && !options.iterations) {
261
+ let iterationsInput = await this.useInput({
262
+ message:
263
+ "Type the number of iterations used when the file was exported",
264
+ validate: (val) => {
265
+ const n = parseInt(val, 10);
266
+ return (
267
+ (n > 0 && String(n) === String(val).trim()) ||
268
+ "Must be a positive integer"
269
+ );
270
+ },
271
+ });
272
+ if (!iterationsInput) {
273
+ throw new Error("Operation canceled");
274
+ }
275
+ options.iterations = parseInt(iterationsInput, 10);
276
+ }
250
277
  c[2] = fileCipher.decryptFile(c[2], options);
251
278
  } catch (e) {
252
279
  this.skipped.push([path.basename(c[0]), e.message]);
@@ -26,10 +26,14 @@ class Quit extends require("../Command") {
26
26
  if (options.help) {
27
27
  return this.showHelp();
28
28
  }
29
+ const wasLoggedIn = Boolean(this.secrez.masterKeyHash);
29
30
  /* istanbul ignore if */
30
31
  // eslint-disable-next-line no-constant-condition
31
32
  if (process.env.NODE_ENV !== "test") {
32
- await this.prompt.saveHistory();
33
+ if (wasLoggedIn) {
34
+ await this.prompt.saveHistory();
35
+ this.secrez.signout();
36
+ }
33
37
  this.Logger.bold(
34
38
  "Clear or close the terminal. If not, your history will be visible scrolling up."
35
39
  );
@@ -37,6 +41,9 @@ class Quit extends require("../Command") {
37
41
  /*eslint-disable-next-line*/
38
42
  process.exit(0);
39
43
  } else {
44
+ if (wasLoggedIn) {
45
+ this.secrez.signout();
46
+ }
40
47
  this.Logger.reset("Bye bye :o)");
41
48
  }
42
49
  }
@@ -1,4 +1,31 @@
1
- const { execSync } = require("child_process");
1
+ const { spawn } = require("child_process");
2
+
3
+ function execShell(command, cwd) {
4
+ return new Promise((resolve, reject) => {
5
+ const child = spawn(command, {
6
+ shell: true,
7
+ cwd,
8
+ });
9
+ let stdout = "";
10
+ let stderr = "";
11
+ child.stdout.on("data", (data) => {
12
+ stdout += data.toString("utf8");
13
+ });
14
+ child.stderr.on("data", (data) => {
15
+ stderr += data.toString("utf8");
16
+ });
17
+ child.on("close", (code) => {
18
+ if (code === 0) {
19
+ resolve(stdout);
20
+ } else {
21
+ reject(
22
+ new Error(stderr.trim() || stdout.trim() || `Exit code ${code}`)
23
+ );
24
+ }
25
+ });
26
+ child.on("error", reject);
27
+ });
28
+ }
2
29
 
3
30
  class Shell extends require("../Command") {
4
31
  setHelpAndCompletion() {
@@ -41,7 +68,7 @@ class Shell extends require("../Command") {
41
68
  })
42
69
  );
43
70
  }
44
- return execSync(`cd ${pwd} && ${options.command}`).toString();
71
+ return execShell(options.command, pwd);
45
72
  }
46
73
 
47
74
  async exec(options = {}) {