मैं अपनी निर्माण प्रक्रिया में watchify
जोड़ रहा हूं लेकिन मैं चलने को देखने के लिए एक पूर्व शर्त रखना चाहता हूं, और यही वह फ़ाइल है जो हमारे लिफ्टिंग चरण को पास करती है (जो ESLint
का उपयोग कर रही है)।रनिफ़ाई चलाने से पहले एस्लिंट चलाएं
मैं ऐसा करने का सोच रहा था:
function runBrowserify(watch){
var babel = babelify.configure({
optional: ['es7.objectRestSpread']
});
var b = browserify({
entries: './app/main.js',
debug: true,
extensions: ['.jsx', '.js'],
cache: {},
packageCache: {},
fullPaths: true
})
.transform(babel);
if(watch) {
// if watch is enable, wrap this bundle inside watchify
b = watchify(b);
b.on('update', function(ids) {
//run the linting step
lint(ids);
//run the watchify bundle step
gutil.log(gutil.colors.blue('watchify'), 'Started');
bundleShare(b);
});
b.on('time', function (time) {
gutil.log(gutil.colors.blue('watchify'), 'Finished', 'after', gutil.colors.magenta(time), gutil.colors.magenta('ms'));
});
}
bundleShare(b);
}
function bundleShare(b) {
b.bundle()
.pipe(source('main.min.js'))
.pipe(gulp.dest('./dist'));
}
function lint(glob) {
return gulp.src(glob)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
}
समस्या है कि linting कदम async है, इसलिए यह बंडलिंग किया जा रहा था जब खत्म नहीं करता है (यह भी थ्रो तो मैं शायद plumber
उपयोग करने की आवश्यकता watch
चरण को समाप्त करने से रोकने के लिए)।
तो bundleShared
पर कॉल करने से पहले मैं पूर्व शर्त कैसे बना सकता हूं?
क्या आपको यह पता चला? – Loknar
नहीं। मुझे उनके लिए एक साथ चलने के लिए व्यवस्थित करना है, इसलिए मुझे कभी-कभी ईएसलिंट त्रुटियों को याद आती है –
मुझे आश्चर्य है कि शायद यह देखने के लिए बंद करने के द्वारा किया जा सकता है। ('अपडेट', func)? https://github.com/substack/watchify मैं इसे कभी-कभी कोशिश करूंगा और आपको –