Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function compareLastModifiedTime(stream, cb, basePath, sourceFile, targetPath) {
if (sourceFile.isNull()) {
cb(null, sourceFile);
return;
}
fs.stat(targetPath, function(err, targetStat) {
if (err) {
if (err.code === 'ENOENT') {
// try reading the file using the oldDest path
var target = path.join(basePath, path.basename(basePath)+'.js');
if (target !== targetPath) {
return compareLastModifiedTime(stream, cb, basePath, sourceFile, target);
}
else {
stream.push(sourceFile);
}
}
else {
stream.emit('error', new gutil.PluginError('gulp-changed', err, {
fileName: sourceFile.path
}));
function (callback) {
fs.stat(uploadDir, function (error) {
// Deliberately passing error to next function for checking
callback(null, error)
})
},
function (error, callback) {
openedZipArchive.openReadStream(entry, function(error, readStream) {
if (error) {
return done(error);
}
var file = path.join(tmpDir, fileName);
fs.stat(file, function(error, stat) {
if (!error && program.debug) {
// File already exists.
return done(null, fileName);
}
readStream.pipe(fs.createWriteStream(file))
.on('error', cb)
.on('close', function() {
done(null, fileName);
});
});
});
}
return
}
// Destination is not an HTTP request
if (self.src && !self.dest) {
stream.Stream.prototype.pipe.call(self, fs.createWriteStream(self.path))
} else if (self.dest && !self.src) {
fs.createReadStream(self.path).pipe(self.dest)
}
}
if (!err && stats.isDirectory()) {
self.path = path.join(self.path, self.index)
self.mimetype = mime.getType(self.path.slice(self.path.lastIndexOf('.')+1))
fs.stat(self.path, finish)
return
} else {
finish(err, stats)
}
if (!self.src && !self.dest) {
if (self.buffers.length > 0) {
stream.Stream.prototype.pipe.call(self, fs.createWriteStream(self.path))
} else if (self.listeners('data').length > 0) {
fs.createReadStream(self.path).pipe(self.dest)
} else {
fs.createReadStream(self.path).pipe(self)
}
}
})
function next(err) {
if (self._extensions.length <= i) {
return err
? self.onStatError(err)
: self.error(404)
}
var p = path + '.' + self._extensions[i++]
debug('stat "%s"', p)
fs.stat(p, function (err, stat) {
if (err) return next(err)
if (stat.isDirectory()) return next()
self.emit('file', p, stat)
self.send(p, stat)
})
}
}
return new Promise((resolve, reject) => {
FS.stat(dir, (err) => err ? reject(err) : resolve())
}).then(() => {
return watchPath(dir, {}, (events) => {
new Promise((resolve, reject) => {
fs.stat(path, (err, file) => {
if (err) {
return reject(err);
}
return resolve(file.isDirectory());
});
});
function isFileOlderThan(f, timestamp, done) {
fs.stat(f, function (err, stat) {
if (err) { return done(err); }
return done(null, stat.mtime < timestamp);
});
}
nfiles.forEach(function (b) {
var file = path.join(f, b);
if (!files[file]) {
fs.stat(file, function (err, stat) {
callback(file, stat, null);
files[file] = stat;
fileWatcher(file);
})
}
})
})
return HorsemanPromise.fromCallback(function(done) {
return fs.stat(path, done);
});
})