From 42b050912a379124bed8b67bc3247f59aff74ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=92=85=20=F0=9F=92=83=20=F0=9F=8C=88=20Miley?= Date: Sun, 12 Aug 2018 15:57:20 -0700 Subject: [PATCH 1/2] Make the parsing of npm pack output more robust npm pack may have additional output with it and when we send all of that output to path.resolve() it results in including a bunch of other output that's not needed. This changes makes us only take the last line of that output which should have the tarball name there. We may want to be a little more clever and not rely on output parsing. (package name + version .tgz instead) Fixes #172 --- packages/jsii-pacmak/bin/jsii-pacmak.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/jsii-pacmak/bin/jsii-pacmak.ts b/packages/jsii-pacmak/bin/jsii-pacmak.ts index b839e6f4b7..df33744f00 100644 --- a/packages/jsii-pacmak/bin/jsii-pacmak.ts +++ b/packages/jsii-pacmak/bin/jsii-pacmak.ts @@ -183,7 +183,8 @@ async function npmPack(packageDir: string, tmpdir: string): Promise { args.push('--loglevel=verbose'); } const out = await shell('npm', args, { cwd: tmpdir }); - return path.resolve(tmpdir, out.trim()); + const lines = out.trim().split(os.EOL); + return path.resolve(tmpdir, lines[lines.length - 1].trim()); } async function updateNpmIgnore(packageDir: string, excludeOutdir: string | undefined) { From 957db1b55a19d8cfe6195930e70ade65f51239e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=92=85=20=F0=9F=92=83=20=F0=9F=8C=88=20Miley?= Date: Mon, 13 Aug 2018 07:11:44 -0700 Subject: [PATCH 2/2] Add comment about stdout and npm pack --- packages/jsii-pacmak/bin/jsii-pacmak.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/jsii-pacmak/bin/jsii-pacmak.ts b/packages/jsii-pacmak/bin/jsii-pacmak.ts index df33744f00..39dadda5a4 100644 --- a/packages/jsii-pacmak/bin/jsii-pacmak.ts +++ b/packages/jsii-pacmak/bin/jsii-pacmak.ts @@ -183,6 +183,9 @@ async function npmPack(packageDir: string, tmpdir: string): Promise { args.push('--loglevel=verbose'); } const out = await shell('npm', args, { cwd: tmpdir }); + // Take only the last line of npm pack which should contain the + // tarball name. otherwise, there can be a lot of extra noise there + // from scripts that emit to STDOUT. const lines = out.trim().split(os.EOL); return path.resolve(tmpdir, lines[lines.length - 1].trim()); }