MCPcopy Create free account
hub / github.com/zxlie/FeHelper / jsMerge

Function jsMerge

gulpfile.js:114–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112// 合并 & 压缩 js
113function processJs(outputDir = 'output-chrome/apps') {
114 let jsMerge = () => {
115 return through.obj(function (file, enc, cb) {
116 let contents = file.contents.toString('utf-8');
117 let merge = (fp, fc) => {
118 return fc.replace(/__importScript\(\s*(['"])([^'"]*)\1\s*\)/gm, function (frag, $1, mod) {
119 let mp = path.resolve(fp, '../' + mod + (/\.js$/.test(mod) ? '' : '.js'));
120 let mc = fs.readFileSync(mp).toString('utf-8');
121 return merge(mp, mc + ';');
122 });
123 };
124 contents = merge(file.path, contents);
125 file.contents = Buffer.from(contents);
126 this.push(file);
127 return cb();
128 })
129 };
130 const shouldSkipProcessing = (file) => {
131 const relativePath = path.relative(path.join(process.cwd(), 'apps'), file.path);
132 return relativePath === 'chart-maker/lib/xlsx.full.min.js'

Callers 1

processJsFunction · 0.85

Calls 2

cbFunction · 0.85
mergeFunction · 0.70

Tested by

no test coverage detected