Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3217ee

Browse files
posvayyx990803
authored andcommitted
Support array in skipInterpolation (vuejs#282)
* Add test to support arrays in skipInterpolation* Support arrays in skipInterpolationClosesvuejs#281Use multimatch instead of match for this purpose.The minimatch dependency has not been removed because it's still used inlib/filter.js. Filters should directly use multimatch. Once thishappens, the dependency to minimatch can be removed.* Remove useless statement
1 parent0d3f96d commitc3217ee

File tree

9 files changed

+80
-2
lines changed

9 files changed

+80
-2
lines changed

‎lib/generate.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var Handlebars = require('handlebars')
33
varasync=require('async')
44
varrender=require('consolidate').handlebars.render
55
varpath=require('path')
6-
varmatch=require('minimatch')
6+
varmultimatch=require('multimatch')
77
vargetOptions=require('./options')
88
varask=require('./ask')
99
varfilter=require('./filter')
@@ -91,12 +91,15 @@ function filterFiles (filters) {
9191
*/
9292

9393
functionrenderTemplateFiles(skipInterpolation){
94+
skipInterpolation=typeofskipInterpolation==='string'
95+
?[skipInterpolation]
96+
:skipInterpolation
9497
returnfunction(files,metalsmith,done){
9598
varkeys=Object.keys(files)
9699
varmetalsmithMetadata=metalsmith.metadata()
97100
async.each(keys,function(file,next){
98101
// skipping files with skipInterpolation option
99-
if(skipInterpolation&&match(file,skipInterpolation,{dot:true})){
102+
if(skipInterpolation&&multimatch([file],skipInterpolation,{dot:true}).length){
100103
returnnext()
101104
}
102105
varstr=files[file].contents.toString()

‎package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"inquirer":"^0.12.0",
4040
"metalsmith":"^2.1.0",
4141
"minimatch":"^3.0.0",
42+
"multimatch":"^2.1.0",
4243
"ora":"^0.2.1",
4344
"read-metadata":"^1.0.0",
4445
"request":"^2.67.0",

‎test/e2e/mock-skip-glob/meta.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"schema": {
3+
"name": {
4+
"type":"string",
5+
"required":true,
6+
"label":"Project name"
7+
},
8+
"description": {
9+
"type":"string",
10+
"required":true,
11+
"label":"Project description",
12+
"default":"A Vue.js project"
13+
},
14+
"author": {
15+
"type":"string",
16+
"label":"Author"
17+
},
18+
"private": {
19+
"type":"boolean",
20+
"default":true
21+
}
22+
},
23+
"skipInterpolation": [
24+
"src/**/*.{vue,js}",
25+
"!src/**/yes.*"
26+
]
27+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name":"{{ name }}",
3+
"description":"{{ description }}",
4+
"author":"{{ author }}",
5+
"devDependencies": {
6+
{{#preprocessor.less}}
7+
"less":"^2.6.1",
8+
{{/preprocessor.less}}
9+
{{#preprocessor.sass}}
10+
"node-sass":"^3.4.2"
11+
{{/preprocessor.sass}}
12+
}
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('{{ no }}')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<p>{{ no }}</p>
3+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('yes.')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
\{{yes}} {{pick}}
3+
</template>

‎test/e2e/test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const MOCK_META_JSON_PATH = './test/e2e/mock-meta-json'
1515
constMOCK_TEMPLATE_REPO_PATH='./test/e2e/mock-template-repo'
1616
constMOCK_TEMPLATE_BUILD_PATH=path.resolve('./test/e2e/mock-template-build')
1717
constMOCK_METADATA_REPO_JS_PATH='./test/e2e/mock-metadata-repo-js'
18+
constMOCK_SKIP_GLOB='./test/e2e/mock-skip-glob'
1819

1920
functionmonkeyPatchInquirer(answers){
2021
// monkey patch inquirer
@@ -155,6 +156,31 @@ describe('vue-cli', () => {
155156
})
156157
})
157158

159+
it('support multiple globs in skipInterpolation',done=>{
160+
monkeyPatchInquirer(answers)
161+
constbinFilePath=`${MOCK_SKIP_GLOB}/template/bin.file`
162+
constwstream=fs.createWriteStream(binFilePath)
163+
wstream.write(crypto.randomBytes(100))
164+
wstream.end()
165+
166+
generate('test',MOCK_SKIP_GLOB,MOCK_TEMPLATE_BUILD_PATH,err=>{
167+
if(err)done(err)
168+
169+
constoriginalVueFileOne=fs.readFileSync(`${MOCK_SKIP_GLOB}/template/src/no.vue`,'utf8')
170+
constoriginalVueFileTwo=fs.readFileSync(`${MOCK_SKIP_GLOB}/template/src/no.js`,'utf8')
171+
constgeneratedVueFileOne=fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/src/no.vue`,'utf8')
172+
constgeneratedVueFileTwo=fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/src/no.js`,'utf8')
173+
174+
expect(originalVueFileOne).to.equal(generatedVueFileOne)
175+
expect(originalVueFileTwo).to.equal(generatedVueFileTwo)
176+
expect(exists(binFilePath)).to.equal(true)
177+
expect(exists(`${MOCK_TEMPLATE_BUILD_PATH}/bin.file`)).to.equal(true)
178+
rm(binFilePath)
179+
180+
done()
181+
})
182+
})
183+
158184
it('validate input value',done=>{
159185
// deep copy
160186
varinvalidName=extend({},answers,{name:'INVALID-NAME'})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp