Skip to content

Commit

Permalink
fixes #423
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Mar 31, 2020
1 parent 66a41f1 commit 2a6d2e6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/publish.ts
Expand Up @@ -99,11 +99,17 @@ export interface IPublishOptions {
ignoreFile?: string;
}

function versionBump(cwd: string = process.cwd(), version?: string, commitMessage?: string): Promise<void> {
async function versionBump(cwd: string = process.cwd(), version?: string, commitMessage?: string): Promise<void> {
if (!version) {
return Promise.resolve(null);
}

const manifest = await readManifest(cwd);

if (manifest.version === version) {
return null;
}

switch (version) {
case 'major':
case 'minor':
Expand All @@ -127,14 +133,15 @@ function versionBump(cwd: string = process.cwd(), version?: string, commitMessag
command = `${command} -m "${commitMessage}"`;
}

// call `npm version` to do our dirty work
return exec(command, { cwd })
.then(({ stdout, stderr }) => {
process.stdout.write(stdout);
process.stderr.write(stderr);
return Promise.resolve(null);
})
.catch(err => Promise.reject(err.message));
try {
// call `npm version` to do our dirty work
const { stdout, stderr } = await exec(command, { cwd });
process.stdout.write(stdout);
process.stderr.write(stderr);
return null;
} catch (err) {
throw err.message;
}
}

export function publish(options: IPublishOptions = {}): Promise<any> {
Expand Down

0 comments on commit 2a6d2e6

Please sign in to comment.