Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update npm-publish.ts #13

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/npm-publish.ts
Original file line number Diff line number Diff line change
@@ -13,21 +13,37 @@ export async function npmPublish(opts: Options = {}): Promise<Results> {

// Get the old and new version numbers
let manifest = await readManifest(options.package, options.debug);
let publishedVersion = await npm.getLatestVersion(manifest.name, options);

// Determine if/how the version has changed
let diff = semver.diff(manifest.version, publishedVersion);
// If checkVersion is false then publish.
if (options.checkVersion) {
let publishedVersion = await npm.getLatestVersion(manifest.name, options);

if (diff || !options.checkVersion) {
// Publish the new version to NPM
await npm.publish(manifest, options);
// Determine if/how the version has changed
let diff = semver.diff(manifest.version, publishedVersion);

if (diff) {
// Publish the new version to NPM
await npm.publish(manifest, options);
}

let results: Results = {
package: manifest.name,
type: diff || "none",
version: manifest.version.raw,
oldVersion: publishedVersion.raw,
dryRun: options.dryRun
};

options.debug("OUTPUT:", results);
return results;
}

await npm.publish(manifest, options);
let results: Results = {
package: manifest.name,
type: diff || "none",
type: "none",
version: manifest.version.raw,
oldVersion: publishedVersion.raw,
oldVersion: "",
dryRun: options.dryRun
};