Skip to content

Commit 2ed21b9

Browse files
Adding license information in package.json
1 parent b0815de commit 2ed21b9

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

generator/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ function buildPrePublishOnly({ useVueStyleguidist, useVueDoc, useLint }) {
1717
return scripts.map(script => `npm run ${script}`).join(' && ')
1818
}
1919

20-
function replaceInLicense(licenseTextTemplate, sourceText, newText){
20+
function replaceInLicense(licenseTextTemplate, sourceText, newText) {
2121
return licenseTextTemplate.replace(new RegExp(`<${sourceText}>`), newText)
22-
.replace(new RegExp(`\\[${sourceText}\\]`), newText)
22+
.replace(new RegExp(`\\[${sourceText}\\]`), newText)
2323
}
24-
24+
2525
module.exports = (api, { addBadges, addLicense, componentName, copyrightHolders, licenseName, useVueDoc, useVueStyleguidist }) => {
2626

2727
const useLint = api.hasPlugin('eslint')
@@ -72,6 +72,12 @@ module.exports = (api, { addBadges, addLicense, componentName, copyrightHolders,
7272
})
7373
}
7474

75+
if (addLicense) {
76+
api.extendPackage({
77+
license : licenseName
78+
})
79+
}
80+
7581
api.render('./template')
7682

7783
api.postProcessFiles(files => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-component",
3-
"version": "1.6.6",
3+
"version": "1.7.1",
44
"description": "vue-cli 3 plugin to create shareable component",
55
"main": "index.js",
66
"repository": {

prompts.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const licenses = licensesInformation.map(name => ({
55
value: name
66
}));
77

8-
module.exports = [
8+
const prompts = module.exports = [
99
{
1010
type: 'input',
1111
name: 'componentName',
@@ -55,4 +55,9 @@ module.exports = [
5555
message: 'Enter copyright holders:',
5656
group: 'License',
5757
},
58-
]
58+
]
59+
60+
module.exports.getPrompts = pkg => {
61+
prompts[0].default = pkg.name
62+
return prompts
63+
}

0 commit comments

Comments
 (0)