すでに答えがあるかもしれませんが、まだ見つけていません。つまり、gulp 経由で更新したいプラグイン (zxing) があります。私のgulpタスク(extern)は次のようになります:
import {nodeModules, scriptsDir} from './paths';
import zxingPkg from '../node_modules/@zxing/library/package.json';
import {src, series, dest} from 'gulp';
import rename from 'gulp-rename';
import replace from 'gulp-replace';
import run from 'gulp-run';
let oldVersion = zxingPkg.version;
let newVersion = '0';
import fs from 'fs';
const paths = {
scripts: {
srcZxing: `${nodeModules}/@zxing/library/umd/index.min.js`,
destZxing: scriptsDir,
}
}
const zxingTask = () => {
return src(paths.scripts.srcZxing)
.pipe(rename(`zxing.${zxingPkg.version}.min.js`))
.pipe(dest(paths.scripts.destZxing));
}
function update() {
return run('npm update @zxing/library').exec();
}
function checknew() {
var obj = JSON.parse(fs.readFileSync('./node_modules/@zxing/library/package.json', 'utf8'));
newVersion = obj.version;
if (newVersion > oldVersion) {
return src('.')
.pipe(series(copyIt, renameInFiles))
.pipe('.');
} else {
return src('.')
.pipe(console.log(`${newVersion} == ${oldVersion}`))
.pipe(dest('.'));
}
}
function copyIt() {
console.log('copy');
return src(`${paths.srcZxing}`)
.pipe(dest(`${paths.destZxing}/zxing.${newVersion}.min.js`));
}
function renameInFiles() {
console.log(`zxing.${oldVersion}.min.js zxing.${newVersion}.min.js`)
return src('./src/appl/framework/functions/**/*')
.pipe(replace(`zxing.${oldVersion}.min.js`, `zxing.${newVersion}.min.js`))
.pipe(dest('./src/appl/framework/functions/**/*.(php|phpi)'))
}
module.exports = series(update);
gulpfile.babel.js は次のようになります。
import zxingTask from './gulptasks/zxing';
...
// zxing => /scripts/zxing.{version}.min.js
const zxing = () => {
return zxingTask();
}
exports.zxing = zxing;
次のエラーが表示されます。
[08:53:14] Starting 'zxing'...
[08:53:14] Starting 'update'...
[08:53:14] 'update' errored after 1.26 ms
[08:53:14] ReferenceError: regeneratorRuntime is not defined
at _update (C:\Users\user\sites\erp\gulptasks\zxing.js:41:45)
at update (C:\Users\user\sites\erp\gulptasks\zxing.js:37:18)
at bound (domain.js:402:14)
at runBound (domain.js:415:12)
at asyncRunner (C:\Users\user\sites\erp\node_modules\async-done\index.js:55:18)
at process._tickCallback (internal/process/next_tick.js:61:11)
エラーがわかりません。私はそれを完全に間違っていますか、それともタスクを実行するのに良い方法ですか?