Skip to content

Commit

Permalink
chg: Use spwan to check perl scripts
Browse files Browse the repository at this point in the history
This avoids ERR_CHILD_PROCESS_STDIO_MAXBUFFER being called if we have too much output.
  • Loading branch information
hangy committed May 4, 2020
1 parent d10877c commit 3bff179
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 58 deletions.
28 changes: 14 additions & 14 deletions check_perl.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
/*eslint no-console: "off"*/
/*eslint no-await-in-loop: "off"*/
/*global process*/

const process = require('process');
const util = require('util');
const glob = util.promisify(require('glob').glob);
const execFile = util.promisify(require('child_process').execFile);
const process = require("process");
const util = require("util");
const glob = util.promisify(require("glob").glob);
const { spawn } = require("child_process");

async function main() {
// 0 = node; 1 = check_perl.js
for (let arg of process.argv.slice(2)) {
for (const arg of process.argv.slice(2)) {
const files = await glob(arg);
for (var i = 0; i < files.length; ++i) {
const path = files[i];
console.log(`Checking ${path}`);
try {
const { stdout, stderr } = await execFile(`perl`, ['-c', '-CS', '-Ilib', files[i]]);
if (stderr) {
console.error(stderr);
}

console.log(stdout);
const child = spawn(`perl`, ["-c", "-CS", "-Ilib", path]);
child.stdout.on("data", (data) => console.log("[" + path + "] " + data));
child.stderr.on("data", (data) => console.error("[" + path + "] " + data));
child.on("close", (code) => {
console.log("[" + path + "] result: " + code);
process.exitCode = code;
});
} catch (e) {
console.error(e);
console.error("[" + path + "] " + e);
process.exitCode = e.code;
throw e;
}
}
}

console.log('Done!');
console.log("Done!");
}

main();
82 changes: 40 additions & 42 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
/*global exports */

const { src, dest, series, parallel } = require("gulp");
const concat = require("gulp-concat");
Expand All @@ -15,8 +15,8 @@ const sassOptions = {
};

function icons() {
return src("*.svg", { cwd: "./icons" })
.pipe(
return src("*.svg", { cwd: "./icons" }).
pipe(
svgmin({
plugins: [
{ removeMetadata: false },
Expand All @@ -30,17 +30,17 @@ function icons() {
}
]
})
)
.pipe(dest("./html/images/icons/dist"));
).
pipe(dest("./html/images/icons/dist"));
}

function css() {
return src("./scss/**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on("error", sass.logError))
.pipe(minifyCSS())
.pipe(sourcemaps.write("."))
.pipe(dest("./html/css/dist"));
return src("./scss/**/*.scss").
pipe(sourcemaps.init()).
pipe(sass(sassOptions).on("error", sass.logError)).
pipe(minifyCSS()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/css/dist"));
}

function copyJs() {
Expand All @@ -59,23 +59,23 @@ function copyJs() {
"./node_modules/blueimp-file-upload/js/*.js",
"./node_modules/@yaireo/tagify/dist/tagify.min.js",
"./node_modules/cropper/dist/*.js"
])
.pipe(sourcemaps.init())
.pipe(terser())
.pipe(sourcemaps.write("."))
.pipe(dest("./html/js/dist"));
]).
pipe(sourcemaps.init()).
pipe(terser()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/js/dist"));
}

function buildJs() {
return src([
'./html/js/display*.js',
'./html/js/product-multilingual.js',
'./html/js/search.js'
])
.pipe(sourcemaps.init())
.pipe(terser())
.pipe(sourcemaps.write("."))
.pipe(dest("./html/js/dist"));
]).
pipe(sourcemaps.init()).
pipe(terser()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/js/dist"));
}

function buildjQueryUi() {
Expand All @@ -88,12 +88,12 @@ function buildjQueryUi() {
'./node_modules/jquery-ui/ui/safe-active-element.js',
'./node_modules/jquery-ui/ui/widgets/autocomplete.js',
'./node_modules/jquery-ui/ui/widgets/menu.js'
])
.pipe(sourcemaps.init())
.pipe(terser())
.pipe(concat('jquery-ui.js'))
.pipe(sourcemaps.write("."))
.pipe(dest('./html/js/dist'))
]).
pipe(sourcemaps.init()).
pipe(terser()).
pipe(concat('jquery-ui.js')).
pipe(sourcemaps.write(".")).
pipe(dest('./html/js/dist'));
}

function jQueryUiThemes() {
Expand All @@ -102,12 +102,12 @@ function jQueryUiThemes() {
'./node_modules/jquery-ui/themes/base/autocomplete.css',
'./node_modules/jquery-ui/themes/base/menu.css',
'./node_modules/jquery-ui/themes/base/theme.css',
])
.pipe(sourcemaps.init())
.pipe(minifyCSS())
.pipe(concat('jquery-ui.css'))
.pipe(sourcemaps.write("."))
.pipe(dest('./html/css/dist/jqueryui/themes/base'));
]).
pipe(sourcemaps.init()).
pipe(minifyCSS()).
pipe(concat('jquery-ui.css')).
pipe(sourcemaps.write(".")).
pipe(dest('./html/css/dist/jqueryui/themes/base'));
}

function copyCss() {
Expand All @@ -118,18 +118,16 @@ function copyCss() {
"./node_modules/@yaireo/tagify/dist/tagify.css",
"./html/css/product-multilingual.css",
"./node_modules/cropper/dist/cropper.css"
])
.pipe(sourcemaps.init())
.pipe(minifyCSS())
.pipe(sourcemaps.write("."))
.pipe(dest("./html/css/dist"));
]).
pipe(sourcemaps.init()).
pipe(minifyCSS()).
pipe(sourcemaps.write(".")).
pipe(dest("./html/css/dist"));
}

function copyImages() {
return src([
"./node_modules/leaflet/dist/**/*.png"
])
.pipe(dest("./html/css/dist"));
return src(["./node_modules/leaflet/dist/**/*.png"]).
pipe(dest("./html/css/dist"));
}

exports.copyJs = copyJs;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test:lang:common": "perl scripts/check_po_file.pl po/common/en.po",
"prove": "prove -l",
"lint": "npm run lint:js && npm run lint:css && npm run lint:scss",
"lint:js": "eslint html/js/product-multilingual.js html/js/search.js html/js/display*.js",
"lint:js": "eslint html/js/product-multilingual.js html/js/search.js html/js/display*.js *.js",
"lint:css": "stylelint html/css/product-multilingual.css",
"lint:scss": "stylelint scss/app.scss",
"perlc": "npm run perlc:startup && npm run perlc:cgi && npm run perlc:scripts",
Expand Down
2 changes: 1 addition & 1 deletion refresh_taxonomies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint no-console: "off"*/
/*eslint no-await-in-loop: "off"*/
/*global process require*/
/*global process */

const util = require('util');
const { spawn, execFile } = require('child_process');
Expand Down

0 comments on commit 3bff179

Please sign in to comment.