-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
pkgRoot
option to publish a sub-directory
- Loading branch information
Showing
11 changed files
with
240 additions
and
71 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 |
---|---|---|
@@ -1,16 +1,18 @@ | ||
const readPkgUp = require('read-pkg-up'); | ||
const readPkg = require('read-pkg'); | ||
const SemanticReleaseError = require('@semantic-release/error'); | ||
|
||
module.exports = async () => { | ||
const {pkg} = await readPkgUp(); | ||
module.exports = async pkgRoot => { | ||
try { | ||
const pkg = await readPkg(pkgRoot); | ||
if (!pkg.name) { | ||
throw new SemanticReleaseError('No "name" found in package.json.', 'ENOPKGNAME'); | ||
} | ||
|
||
if (!pkg) { | ||
throw new SemanticReleaseError('A package.json file is required to release on npm.', 'ENOPKG'); | ||
return pkg; | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { | ||
throw new SemanticReleaseError('A package.json file is required to release on npm.', 'ENOPKG'); | ||
} | ||
throw err; | ||
} | ||
|
||
if (!pkg.name) { | ||
throw new SemanticReleaseError('No "name" found in package.json.', 'ENOPKGNAME'); | ||
} | ||
|
||
return pkg; | ||
}; |
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
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
Oops, something went wrong.