Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #32818 from samgiles/support-remove-in-preprocessor
Browse files Browse the repository at this point in the history
Bug 1219302 - Support removing files using the preprocessor when a flag is enabled r=rchien
  • Loading branch information
fabricedesre committed Nov 6, 2015
2 parents 86d6d0b + 04177bb commit b9fe675
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions build/preprocessor.js
Expand Up @@ -106,10 +106,16 @@ function processFiles(flag, enable, list, stagePath) {
['index.html'],
['elements', 'root.html']
],
remove:[ // Remove all files in the array when the flag is disabled.
['js', 'example.js'],
['elements', 'example.html']
]
remove: {
"ifndef": [ // Remove all files in the array when the flag is disabled.
['js', 'example.js'],
['elements', 'example.html']
],
"ifdef": [ // Remove all the files in the array when the flag is enabled.
['js', 'other_example.js'],
['elements', 'other_example.html']
]
}
};
// Enable:
Expand All @@ -123,7 +129,24 @@ exports.execute = function(options, flag, list) {

processFiles(flag, enable, list.process, stagePath);

if (!enable && list.remove) {
removeFiles(stagePath, list.remove);
if (list.remove) {

// For backwards compatibility - if the the remove list is an array, remove
// if the flag is NOT enabled.
if (Array.isArray(list.remove)) {
if (!enable) {
removeFiles(stagePath, list.remove);
}
} else {
if (enable) {
if (list.remove.ifdef) {
removeFiles(stagePath, list.remove.ifdef);
}
} else {
if (list.remove.ifndef) {
removeFiles(stagePath, list.remove.ifndef);
}
}
}
}
};

0 comments on commit b9fe675

Please sign in to comment.