Skip to content

Commit

Permalink
Add the publish option (#82)
Browse files Browse the repository at this point in the history
Add the ability to control if the package is private or not.
By default, only copyrighted projects are private.
  • Loading branch information
BenjaminVanRyseghem authored and SBoudrias committed Mar 29, 2018
1 parent 9959d5a commit 9ec3d42
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ module.exports = class GeneratorLicense extends Generator {
required: false,
defaults: 'LICENSE'
});

this.option('publish', {
type: Boolean,
desc: 'Publish the package',
required: false
});
}

initializing() {
Expand Down Expand Up @@ -155,9 +161,10 @@ module.exports = class GeneratorLicense extends Generator {
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
pkg.license = this.props.license;

// We don't want users to publish their module to NPM if they copyrighted
// their content.
if (this.props.license === 'UNLICENSED') {
if (
(this.options.publish === undefined && this.props.license === 'UNLICENSED') ||
this.options.publish === false
) {
delete pkg.license;
pkg.private = true;
}
Expand Down

0 comments on commit 9ec3d42

Please sign in to comment.