forked from lerna/lerna
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(publish): Add a "from-git" argument
Publish un-published releases by reading versions from the package.json files and publishing any that are not already available in the registry. Fixes lerna#1648
- Loading branch information
1 parent
159a0b0
commit 0975615
Showing
3 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use strict"; | ||
|
||
const fetch = require("npm-registry-fetch"); | ||
const log = require("npmlog"); | ||
const pReduce = require("p-reduce"); | ||
|
||
module.exports = getUnpublishedPackages; | ||
|
||
function getUnpublishedPackages(project, opts) { | ||
log.silly("getPackageVersions"); | ||
|
||
let chain = Promise.resolve(); | ||
|
||
const mapper = (unpublished, pkg) => | ||
fetch(`-/${pkg.name}`, opts).then( | ||
packument => { | ||
if (packument.versions[pkg.version] === undefined) { | ||
unpublished.push(pkg); | ||
} | ||
|
||
return unpublished; | ||
}, | ||
() => { | ||
log.warn("", "Unable to determine published versions, assuming unpublished."); | ||
return unpublished.concat([pkg]); | ||
} | ||
); | ||
|
||
chain = chain.then(() => project.getPackages()); | ||
chain = chain.then(packages => pReduce(packages, mapper, [])); | ||
|
||
return chain; | ||
} |