Skip to content

Commit 610099a

Browse files
authoredSep 7, 2020
Fix first-time package publishing, fixes #11
1 parent 5a905d1 commit 610099a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎src/npm.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@ export const npm = {
2727
options.debug(`Running command: npm view ${name} version`);
2828

2929
// Run NPM to get the latest published version of the package
30-
let { stdout } = await ezSpawn.async("npm", ["view", name, "version"], { env });
30+
let { stdout, stderr } = await ezSpawn.async("npm", ["view", name, "version"], { env });
31+
32+
// If the package was not previously published, return version 0.0.0.
33+
if (stderr && stderr.indexOf('E404') !== -1) {
34+
options.debug(`The latest version of ${name} is at v0.0.0, as it was never published.`);
35+
return new SemVer("0.0.0");
36+
}
37+
3138
let version = stdout.trim();
3239

3340
// Parse/validate the version number
3441
let semver = new SemVer(version);
3542

36-
options.debug(`The local version of ${name} is at v${semver}`);
43+
options.debug(`The latest version of ${name} is at v${semver}`);
3744
return semver;
3845
}
3946
catch (error) {

0 commit comments

Comments
 (0)
Failed to load comments.