Skip to content

Add license prompt #92

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"test": "grunt test"
},
"dependencies": {
"prompt": "~0.1.12",
"semver": "~1.0.14",
"hooker": "~0.2.3",
"async": "~0.2.10",
"colors": "~0.6.0-1",
"grunt": "~0.4.0",
"hooker": "~0.2.3",
"lodash": "~2.4.1",
"async": "~0.2.10"
"prompt": "~0.1.12",
"semver": "~1.0.14",
"spdx": "^0.4.1"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.8.0",
Expand Down
13 changes: 12 additions & 1 deletion tasks/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function(grunt) {

// External libs.
var semver = require('semver');
var spdx = require('spdx');
var _ = require('lodash');

// Internal libs.
Expand Down Expand Up @@ -125,6 +126,7 @@ module.exports = function(grunt) {
keywords: {
message: 'Project keywords (separated by space)',
sanitize: function(value, data, done) {
/*jshint laxbreak:true*/
done(null, value
? value.replace(/^\s+|\s+$/g, '')
.split(/\s+/)
Expand Down Expand Up @@ -204,6 +206,14 @@ module.exports = function(grunt) {
},
warning: 'Should be a public URL.'
},
license: {
message: 'License',
default: 'MIT',
validator: spdx.valid,
warning: 'Must be a valid SPDX License Expression (spdx.org). Built-in ' +
'licenses are: ' + helpers.availableLicenses().join(' ') + ', but you may ' +
'specify any valid license expression.'
},
licenses: {
message: 'Licenses',
default: 'MIT',
Expand Down Expand Up @@ -412,7 +422,7 @@ module.exports = function(grunt) {
writePackageJSON: function(filename, props, callback) {
var pkg = {};
// Basic values.
['name', 'title', 'description', 'version', 'homepage'].forEach(function(prop) {
['name', 'title', 'description', 'version', 'homepage', 'license'].forEach(function(prop) {
if (prop in props) { pkg[prop] = props[prop]; }
});
// Author.
Expand Down Expand Up @@ -487,6 +497,7 @@ module.exports = function(grunt) {
grunt.util.spawn({cmd: 'npm', args: ['install'],
opts: {cwd: init.destpath, stdio: 'inherit'}},
function(error, result, code) {
/*jshint unused:vars*/
if (done) {
done();
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/lib/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ exports.init = function(grunt, helpers) {
// Sanitize function for Yes/No values that converts value to boolean
exports.sanitizeYesNo = function(value, data, done) {
done(null, value !== 'y/N' && /^\s*y[es\s]*/i.test(value));
}
};

return exports;
};