Skip to content

Commit 5951b30

Browse files
committed
fix: stream command output to stdout and stderr
1 parent ae925af commit 5951b30

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

lib/prepare.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ module.exports = async ({tarballDir, pkgRoot}, {cwd, env, stdout, stderr, nextRe
99

1010
if (tarballDir) {
1111
logger.log('Creating npm package version %s', version);
12-
const {stdout: npmStdout, stderr: npmStderr} = await execa('npm', ['pack', basePath], {cwd, env});
13-
stdout.write(npmStdout);
14-
stderr.write(npmStderr);
12+
const result = execa('npm', ['pack', basePath], {cwd, env});
13+
result.stdout.pipe(
14+
stdout,
15+
{end: false}
16+
);
17+
result.stderr.pipe(
18+
stderr,
19+
{end: false}
20+
);
1521

16-
const tarball = npmStdout.split('\n').pop();
22+
const tarball = (await result).stdout.split('\n').pop();
1723
await move(path.resolve(cwd, tarball), path.resolve(cwd, tarballDir.trim(), tarball));
1824
}
1925
};

lib/publish.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@ module.exports = async ({npmPublish, pkgRoot}, pkg, context) => {
1818
const registry = getRegistry(pkg, context);
1919

2020
logger.log('Publishing version %s to npm registry', version);
21-
const {stdout: npmStdout, stderr: npmStderr} = await execa('npm', ['publish', basePath, '--registry', registry], {
21+
const result = execa('npm', ['publish', basePath, '--registry', registry], {
2222
cwd,
2323
env,
2424
});
25-
stdout.write(npmStdout);
26-
stderr.write(npmStderr);
25+
result.stdout.pipe(
26+
stdout,
27+
{end: false}
28+
);
29+
result.stderr.pipe(
30+
stderr,
31+
{end: false}
32+
);
33+
await result;
2734

2835
logger.log(`Published ${pkg.name}@${pkg.version} on ${registry}`);
2936
return getReleaseInfo(pkg, context, registry);

0 commit comments

Comments
 (0)