This repository has been archived by the owner on Jan 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from cssstats/v2
V2
- Loading branch information
Showing
31 changed files
with
4,802 additions
and
57,585 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
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 |
---|---|---|
@@ -1,43 +1,43 @@ | ||
#!/usr/bin/env node | ||
|
||
var program = require('commander'); | ||
var cssstats = require('..'); | ||
var fs = require('fs'); | ||
var stdin = require('stdin'); | ||
var program = require('commander') | ||
var cssstats = require('..') | ||
var fs = require('fs') | ||
var stdin = require('stdin') | ||
|
||
var version = '1.6.0' | ||
|
||
console.log('CSS Statistics CLI (' + version + ')'); | ||
console.log('CSS Statistics CLI (' + version + ')') | ||
|
||
program | ||
.version(version); | ||
.version(version) | ||
|
||
program | ||
.command('file [file]') | ||
.description('read a local css file') | ||
.action(function(file) { | ||
.action(function (file) { | ||
if (!file) { | ||
console.log('Please specify a CSS file'); | ||
return; | ||
console.log('Please specify a CSS file') | ||
return | ||
} | ||
|
||
try { | ||
var css = fs.readFileSync(file, 'utf8'); | ||
console.log(JSON.stringify(cssstats(css), null, 2)); | ||
var css = fs.readFileSync(file, 'utf8') | ||
console.log(JSON.stringify(cssstats(css), null, 2)) | ||
} catch (e) { | ||
console.log('CSS Statistics encountered an error reading ' + file); | ||
console.log(e); | ||
console.log('CSS Statistics encountered an error reading ' + file) | ||
console.log(e) | ||
} | ||
}); | ||
}) | ||
|
||
program.parse(process.argv); | ||
program.parse(process.argv) | ||
|
||
if (!program.args.length) { | ||
console.log('Input some CSS\n^C to cancel\n^D when complete'); | ||
console.log('Input some CSS\n^C to cancel\n^D when complete') | ||
|
||
stdin(function(css) { | ||
stdin(function (css) { | ||
if (css) { | ||
console.log(JSON.stringify(cssstats(css), null, 2)); | ||
console.log(JSON.stringify(cssstats(css), null, 2)) | ||
} | ||
}); | ||
}) | ||
} |
Oops, something went wrong.