Skip to content

Commit de60d9f

Browse files
committed
feat: read existing files during plugin invocation (close #873)
1 parent dbbc96b commit de60d9f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/@vue/cli/lib/invoke.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const fs = require('fs')
22
const path = require('path')
33
const execa = require('execa')
44
const chalk = require('chalk')
5+
const globby = require('globby')
56
const resolve = require('resolve')
67
const inquirer = require('inquirer')
78
const Generator = require('./Generator')
@@ -27,6 +28,20 @@ function load (request, context) {
2728
}
2829
}
2930

31+
async function readFiles (context) {
32+
const files = await globby(['**'], {
33+
cwd: context,
34+
onlyFiles: true,
35+
gitignore: true,
36+
ignore: ['**node_modules**']
37+
})
38+
const res = {}
39+
for (const file of files) {
40+
res[file] = fs.readFileSync(path.resolve(context, file), 'utf-8')
41+
}
42+
return res
43+
}
44+
3045
async function invoke (pluginName, options = {}, context = process.cwd()) {
3146
delete options._
3247
const pkgPath = path.resolve(context, 'package.json')
@@ -84,6 +99,7 @@ async function invoke (pluginName, options = {}, context = process.cwd()) {
8499
const generator = new Generator(context, {
85100
pkg,
86101
plugins: [plugin],
102+
files: await readFiles(context),
87103
completeCbs: createCompleteCbs
88104
})
89105

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy