-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from chromaui/ghengeveld/ch-1486-cli-custom-n…
…pm-registry-support Add support for custom npm registry url
- Loading branch information
Showing
3 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { spawn } from 'yarn-or-npm'; | ||
|
||
export default (args: Parameters<typeof spawn>[0], options: Parameters<typeof spawn>[1] = {}) => | ||
new Promise<string>((resolve, reject) => { | ||
let stdout = ''; | ||
let stderr = ''; | ||
const child = spawn(args, options); | ||
child.stdout.on('data', (chunk) => { | ||
stdout += chunk; | ||
}); | ||
child.stderr.on('data', (chunk) => { | ||
stderr += chunk; | ||
}); | ||
child.on('error', reject); | ||
child.on('close', (code) => { | ||
if (code === 0) resolve(stdout.trim()); | ||
else reject(new Error(stderr)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters