Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Add a verbose flag to output sass warnings. (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
notlee authored Mar 8, 2018
1 parent 5d555dc commit a5bd3a7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ If you have any issues with OBT, please check out [troubleshooting guide](https:
--demo-filter=<demo-name> Build a specific demo. E.G. --demo-filter=pa11y to build only the pa11y.html demo.
--suppress-errors Do not error if no demos are found when using the --demo-filter option.
--debug Keep the test runner open to enable debugging in any browser.
--verbose Output sass warnings with backtraces.

### Developing products

Expand Down
1 change: 1 addition & 0 deletions lib/origami-build-tools-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const help = `
--demo-filter=<demo-name> Build a specific demo. E.G. --demo-filter=pa11y to build only the pa11y.html demo.
--suppress-errors Do not error if no demos are found when using the --demo-filter option.
--debug Keep the test runner open to enable debugging in any browser.
--verbose Output sass warnings with backtraces.
Full documentation
http://git.io/bBjMNw
Expand Down
3 changes: 2 additions & 1 deletion lib/tasks/build-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ module.exports = function buildSass(config) {

// This is an experimental LibSass feature. Use with caution.
// https://github.com/sass/node-sass#functions--v300---experimental
// We use this to silence the sass console output when running `obt test`
// We use this to silence the sass console output when running `obt test`.
// We also use this to hide warnings when building sass without the verbose flag.
functions: config.sassFunctions ? config.sassFunctions : {},
};

Expand Down
25 changes: 14 additions & 11 deletions lib/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ module.exports = function (cfg) {
{
title: 'Compiling Sass',
task: (context, task) => {
let output = '';
config.sassFunctions = {
'@warn': function (warning) {
if (output) {
output += '\n' + warning.getValue().replace(/\n/g, ' ');
} else {
output = warning.getValue().replace(/\n/g, ' ');
// Only include sass warnings with the verbose flag.
if (!config.verbose) {
let output = '';
config.sassFunctions = {
'@warn': function (warning) {
if (output) {
output += '\n' + warning.getValue().replace(/\n/g, ' ');
} else {
output = warning.getValue().replace(/\n/g, ' ');
}
task.output = output;
return nodeSass.NULL;
}
task.output = output;
return nodeSass.NULL;
}
};
};
}
return buildSass(config);
},
skip: () => {
Expand Down
14 changes: 9 additions & 5 deletions lib/tasks/demo-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ function buildSass(buildConfig) {
sourcemaps: true,
buildCss: path.basename(buildConfig.demo.sass).replace('.scss', '.css'),
buildFolder: dest,
sassFunctions: {
cwd: buildConfig.cwd
};

// Only output sass warnings with the verbose flag.
if (! buildConfig.verbose) {
sassConfig.sassFunctions = {
'@warn': function () {
return nodeSass.NULL;
}
},
cwd: buildConfig.cwd
};
};
}

return buildsass(sassConfig);
});
Expand Down Expand Up @@ -414,10 +418,10 @@ module.exports = function (cfg) {
const p = [];

for (const demo of demos) {
// log.secondary('Building demo ' + demo.name);

const buildConfig = {
demo: demo,
verbose: config.verbose,
cwd: cwd
};

Expand Down

0 comments on commit a5bd3a7

Please sign in to comment.