-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sean King
committed
Aug 2, 2015
1 parent
91c67d3
commit 958cbec
Showing
4 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env node | ||
/*eslint no-process-exit: 0 */ | ||
'use strict'; | ||
|
||
var fs = require('fs'), | ||
path = require('path'), | ||
read = require('read-file-stdin'), | ||
write = require('write-file-stdout'), | ||
rucksack = require('../'), | ||
opts = require('minimist'); | ||
|
||
// Set shorthand aliases for options | ||
opts = opts(process.argv.slice(2), { | ||
boolean: [ | ||
'autoprefixer', | ||
'fallbacks', | ||
'colors' | ||
], | ||
alias: { | ||
h: 'help', | ||
s: 'sourcemap', | ||
v: 'version' | ||
} | ||
}); | ||
|
||
var file = opts._[0], | ||
out = opts._[1]; | ||
|
||
// Fetch verion from package.json | ||
if (opts.version) { | ||
return console.log(require('../package.json').version); | ||
} | ||
|
||
// Pipe out help doc from help.txt | ||
if (file === 'help' || opts.help) { | ||
return fs.createReadStream(path.join(__dirname, '/usage.txt')) | ||
.pipe(process.stdout) | ||
.on('close', function() { | ||
process.exit(1); | ||
}); | ||
} | ||
|
||
read(file, function(err, buf) { | ||
|
||
if (err) { | ||
throw err; | ||
} | ||
|
||
if (file) { | ||
opts.from = file; | ||
} | ||
|
||
if (out) { | ||
opts.to = out; | ||
} | ||
|
||
write(out, rucksack.process(String(buf), opts)); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Usage: rucksack [input] [output] {OPTIONS} | ||
|
||
Options: | ||
|
||
--no-autoprefixer Disable automatic vendor prefixing. | ||
|
||
--no-fallbacks Disable legacy fallbacks. | ||
|
||
--no-colors Disable default color replacements. | ||
|
||
--version, -v Show the version number. | ||
|
||
--help, -h Show this help screen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters