Skip to content

Commit 5aca387

Browse files
authored
chore: add preview script
1 parent 1e29bf4 commit 5aca387

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

init.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ const kleur = require('kleur')
66
const path = require('path')
77
const readline = require('readline-sync')
88

9+
const argv = process.argv.slice(2)
10+
911
/**
1012
* Prompt user for input to populate template files
1113
*/
12-
const npmName = readline.question(
13-
'✍️ What is the npm name of your component? '
14-
)
14+
const npmName = argv.includes('--test')
15+
? 'v-test'
16+
: readline.question(
17+
'✍️ What is the npm name of your component? '
18+
)
1519

1620
const componentName = kebabcasify(npmName)
1721
const outDir = path.join(process.cwd(), componentName)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"generator"
2222
],
2323
"scripts": {
24-
"test": "echo \"Info: no test specified\""
24+
"test": "echo \"Info: no test specified\"",
25+
"preview": "node init --test && cd v-test && yarn --registry=https://registry.npm.taobao.org && yarn doc"
2526
},
2627
"dependencies": {
2728
"fs-extra": "^7.0.1",

templates/src/component.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div class="{{componentName}}">
3+
hello
34
</div>
45
</template>
56

0 commit comments

Comments
 (0)