2017-06-20 23:18:46 +00:00
|
|
|
const colors = require('colors/safe');
|
|
|
|
|
|
|
|
const getBrowserify = require('./browserify');
|
|
|
|
const getCopy = require('./copy');
|
|
|
|
const getJS = require('./js');
|
|
|
|
const getSass = require('./sass');
|
|
|
|
const getSymlinks = require('./symlinks');
|
2019-03-28 18:52:22 +00:00
|
|
|
const getPDFReader = require('./pdf-reader');
|
|
|
|
const getPDFWorker = require('./pdf-worker');
|
2021-02-11 19:48:27 +00:00
|
|
|
const getZoteroNoteEditor = require('./note-editor');
|
2017-06-20 23:18:46 +00:00
|
|
|
const { formatDirsForMatcher, getSignatures, writeSignatures, cleanUp, onSuccess, onError} = require('./utils');
|
2017-05-22 23:10:03 +00:00
|
|
|
const { dirs, symlinkDirs, copyDirs, symlinkFiles, jsFiles, scssFiles, ignoreMask } = require('./config');
|
2017-06-20 23:18:46 +00:00
|
|
|
|
|
|
|
if (require.main === module) {
|
|
|
|
(async () => {
|
|
|
|
try {
|
|
|
|
const t1 = Date.now();
|
|
|
|
global.isError = false; // used to prevent further output to avoid concealing errors
|
|
|
|
const symlinks = symlinkFiles
|
|
|
|
.concat(dirs.map(d => `${d}/**`))
|
|
|
|
.concat([`!${formatDirsForMatcher(dirs)}/**/*.js`])
|
2018-12-12 10:34:39 +00:00
|
|
|
.concat([`!${formatDirsForMatcher(dirs)}/**/*.jsx`])
|
2021-02-24 15:36:27 +00:00
|
|
|
.concat([`!${formatDirsForMatcher(dirs)}/**/*.scss`])
|
|
|
|
.concat([`!${formatDirsForMatcher(copyDirs)}/**`]);
|
2017-06-20 23:18:46 +00:00
|
|
|
|
|
|
|
const signatures = await getSignatures();
|
2022-05-25 14:21:27 +00:00
|
|
|
|
|
|
|
// Check if all files in signatures are still present in src; Needed to avoid a problem
|
|
|
|
// where what was a symlink before, now is compiled, resulting in polluting source files
|
|
|
|
onSuccess(await cleanUp(signatures));
|
|
|
|
|
2017-06-20 23:18:46 +00:00
|
|
|
const results = await Promise.all([
|
|
|
|
getBrowserify(signatures),
|
|
|
|
getCopy(copyDirs.map(d => `${d}/**`), { ignore: ignoreMask }, signatures),
|
|
|
|
getJS(jsFiles, { ignore: ignoreMask }, signatures),
|
2021-02-24 15:36:27 +00:00
|
|
|
...scssFiles.map(scf => getSass(scf, { ignore: ignoreMask }, signatures)),
|
2017-06-20 23:18:46 +00:00
|
|
|
getSymlinks(symlinks, { nodir: true, ignore: ignoreMask }, signatures),
|
|
|
|
getSymlinks(symlinkDirs, { ignore: ignoreMask }, signatures),
|
2019-03-28 18:52:22 +00:00
|
|
|
getPDFReader(signatures),
|
|
|
|
getPDFWorker(signatures),
|
|
|
|
getZoteroNoteEditor(signatures)
|
2017-06-20 23:18:46 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
await writeSignatures(signatures);
|
|
|
|
for (const result of results) {
|
|
|
|
onSuccess(result);
|
|
|
|
}
|
|
|
|
const t2 = Date.now();
|
|
|
|
console.log(colors.yellow(`Total build time ${t2 - t1}ms`));
|
|
|
|
} catch (err) {
|
|
|
|
process.exitCode = 1;
|
|
|
|
global.isError = true;
|
|
|
|
onError(err);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}
|