Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions hooks/01_removeNotRelevantParts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const path = require('path');
const rimraf = require('rimraf');
const fs = require('fs');

const callback = (error) => {
if (error) {
throw error;
}
};

/**
* Removes unnecessary files (css, js) if user pass `singleFile` parameter.
*/
Expand All @@ -21,8 +21,15 @@ module.exports = {
maxBusyTries: 3
};

rimraf.sync(jsDir, opts, callback);
rimraf.sync(cssDir, opts, callback);
// Attempt to delete jsDir if it exists
if (fs.existsSync(jsDir)) {
rimraf.sync(jsDir, opts, callback);
}

// Attempt to delete cssDir if it exists
if (fs.existsSync(cssDir)) {
rimraf.sync(cssDir, opts, callback);
}
}
}
};
};