Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((res, rej) => {
dir.readFilesStream(queuedFilesDir,
{ match: /\.json$/,
recursive: false
},
(err, stream, next) => {
if (err) return rej(err);
console.log('found file to process: %s', stream.path);
const lineReader = readline.createInterface({
input: stream,
terminal: false
});
lineReader
.on('line', line => {
let altered = alterTweet(line);
if (altered) {
// TODO: would be better to stream
return new Promise((res, rej) => {
dir.readFilesStream(queuedImagesDir,
{ match: /\.(jpg|jpeg|png)$/,
recursive: false
},
(err, stream, next) => {
if (err) return rej(err);
let f = stream.path,
renamed = f;
console.log('found image to featurize: %s', f);
// mark complete
if (process.env.NODE_ENV === 'production') {
renamed = path.join(processedImagesDir, path.basename(f));
fs.renameSync(f, renamed);
}
triggerFeaturizer(renamed)
.then(key => queue.add(key))
.then(() => next())
export default function jadeAutoRouting(app, excludePattern) {
dir.readFilesStream(VIEWS_PATH, {match: /.jade$/},
(err, stream, filename, next) => {
if(err) {
console.log(err);
return;
}
let fileNameWithExtension = path.basename(filename);
let fileNameWithoutExtension = path.basename(filename, '.jade');
if(excludePattern != null &&
fileNameWithExtension.match(excludePattern)) {
return;
}
console.log('Auto route to: ./' + fileNameWithoutExtension);
app.get('/' + fileNameWithoutExtension, function(req, resp) {