mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 01:10:41 -07:00
Set up Grunt
Fixing up Grunt file to watch for directories Exclude node modules folder from Jekyll built site
This commit is contained in:
+124
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var csswring = require('../index');
|
||||
var fs = require('fs');
|
||||
var minimist = require('minimist');
|
||||
var pkg = require('../package.json');
|
||||
|
||||
var showHelp = function () {
|
||||
console.log('Usage: csswring [options] INPUT [OUTPUT]');
|
||||
console.log('');
|
||||
console.log('Description:');
|
||||
console.log(' ' + pkg.description);
|
||||
console.log('');
|
||||
console.log('Options:');
|
||||
console.log(' --sourcemap Create source map file.');
|
||||
console.log(' --preserve-hacks Preserve some CSS hacks.');
|
||||
console.log(' --remove-all-comments Remove all comments.');
|
||||
console.log(' -h, --help Show this message.');
|
||||
console.log(' -v, --version Print version information.');
|
||||
console.log('');
|
||||
console.log('Use a single dash for INPUT to read CSS from standard input.');
|
||||
|
||||
return;
|
||||
};
|
||||
var wring = function (s, o) {
|
||||
var wringed = csswring(o.csswring).wring(s, o.postcss);
|
||||
|
||||
if (!o.postcss.to) {
|
||||
process.stdout.write(wringed.css);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fs.writeFileSync(o.postcss.to, wringed.css);
|
||||
|
||||
if (wringed.map) {
|
||||
fs.writeFileSync(o.postcss.to + '.map', wringed.map);
|
||||
}
|
||||
};
|
||||
var argv = minimist(process.argv.slice(2), {
|
||||
boolean: [
|
||||
'help',
|
||||
'preserve-hacks',
|
||||
'remove-all-comments',
|
||||
'sourcemap',
|
||||
'version'
|
||||
],
|
||||
alias: {
|
||||
'h': 'help',
|
||||
'v': 'version'
|
||||
},
|
||||
default: {
|
||||
'help': false,
|
||||
'preserve-hacks': false,
|
||||
'remove-all-comments': false,
|
||||
'sourcemap': false,
|
||||
'version': false
|
||||
}
|
||||
});
|
||||
|
||||
if (argv._.length < 1) {
|
||||
argv.help = true;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case argv.version:
|
||||
console.log('csswring v' + pkg.version);
|
||||
|
||||
break;
|
||||
|
||||
case argv.help:
|
||||
showHelp();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
var options = {
|
||||
csswring: {},
|
||||
postcss: {}
|
||||
};
|
||||
|
||||
if (argv['preserve-hacks']) {
|
||||
options.csswring.preserveHacks = true;
|
||||
}
|
||||
|
||||
if (argv['remove-all-comments']) {
|
||||
options.csswring.removeAllComments = true;
|
||||
}
|
||||
|
||||
if (argv.sourcemap) {
|
||||
options.postcss.map = true;
|
||||
}
|
||||
|
||||
options.postcss.from = argv._[0];
|
||||
|
||||
if (argv._[1]) {
|
||||
options.postcss.to = argv._[1];
|
||||
}
|
||||
|
||||
if (options.postcss.map && options.postcss.to) {
|
||||
options.postcss.map = {
|
||||
inline: false
|
||||
};
|
||||
}
|
||||
|
||||
var css = '';
|
||||
|
||||
if (options.postcss.from !== '-') {
|
||||
css = fs.readFileSync(options.postcss.from, 'utf8');
|
||||
wring(css, options);
|
||||
} else {
|
||||
delete options.postcss.from;
|
||||
var stdin = process.openStdin();
|
||||
stdin.setEncoding('utf-8');
|
||||
stdin.on('data', function (chunk) {
|
||||
css += chunk;
|
||||
});
|
||||
stdin.on('end', function () {
|
||||
wring(css, options);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user