Skip to content

Commit

Permalink
[NO-JIRA] Safer transpilation error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gillams committed Jan 23, 2020
1 parent 0bd2341 commit 645b698
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions scripts/build-sass-in-place.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ const { exec, execSync } = require('child_process');

const auxilliaryFiles = ['dist/tokens/_common.scss'];

const blue = s => '\033[0;34m' + s + '\033[0m';

const transpile = file => {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
const outputFile = path.dirname(file);
const options =
'--importer=node_modules/node-sass-tilde-importer --include-path=node_modules --include-path=src';
exec(
`npm run node-sass -- ${options} "${file}" --output="${outputFile}"`,
null,
() => {
(error, stdout, stderr) => {
if (error) {
reject(error);
return;
}
console.info(blue(file));
resolve();
},
);
Expand Down Expand Up @@ -47,13 +53,18 @@ const sleep = milliseconds => {
return new Promise(resolve => setTimeout(resolve, milliseconds));
};

Promise.all(transpilationTasks).then(() => {
sleep(1000).then(() => {
scssFiles.forEach(sF => {
deleteFile(sF);
});
Promise.all(transpilationTasks)
.then(() => {
sleep(1000).then(() => {
scssFiles.forEach(sF => {
deleteFile(sF);
});

console.log('All good. 👍');
process.exit(0);
console.log('All good. 👍');
process.exit(0);
});
})
.catch(err => {
console.error(err);
process.exit(1);
});
});

0 comments on commit 645b698

Please sign in to comment.