Commit e016d857 by Adeel

CLI: Overrides default version info.

* Based on sindresorhus/meow#2.
* Adds alias -v.
* Improves info text; inspired by Less CLI. :)
* Updates readme.

PR URL: #717.
parent 9bd034c2
......@@ -232,14 +232,19 @@ console.log(result.stats);
### Version information (v2 change)
Both `node-sass` and `libsass` version info is now present in `package.json` and is exposed via `info()` method:
Both `node-sass` and `libsass` version info is now present in `package.json` and is exposed via `info` method:
```javascript
require('node-sass').info();
var sass = require('node-sass');
console.log(sass.info);
/*
it will output something like:
// outputs something like:
// node-sass version: 2.0.0-beta
// libsass version: 3.1.0-beta
node-sass 2.0.1 (Wrapper) [JavaScript]
libsass 3.1.0 (Sass Compiler) [C/C++]
*/
```
## Integrations
......@@ -329,6 +334,7 @@ Output will be saved with the same name as input SASS file into the current work
-o, --output Output directory
-x, --omit-source-map-url Omit source map URL comment from output
-i, --indented-syntax Treat data from stdin as sass code (versus scss)
-v, --version Prints version info
--output-style CSS output style (nested|expanded|compact|compressed)
--source-comments Include debug info in output
--source-map Emit source map
......
#!/usr/bin/env node
var Emitter = require('events').EventEmitter,
path = require('path'),
Gaze = require('gaze'),
meow = require('meow'),
stdin = require('get-stdin'),
grapher = require('sass-graph'),
render = require('../lib/render');
meow = require('meow'),
path = require('path'),
render = require('../lib/render'),
stdin = require('get-stdin');
/**
* Initialize CLI
......@@ -13,9 +13,8 @@ var Emitter = require('events').EventEmitter,
var cli = meow({
pkg: '../package.json',
version: process.sassInfo,
help: [
require('../lib/').info(),
'',
'Usage',
' node-sass [options] <input.scss> [output.css]',
' cat <input.scss> | node-sass > output.css',
......@@ -30,6 +29,7 @@ var cli = meow({
' -o, --output Output directory',
' -x, --omit-source-map-url Omit source map URL comment from output',
' -i, --indented-syntax Treat data from stdin as sass code (versus scss)',
' -v, --version Prints version info',
' --output-style CSS output style (nested|expanded|compact|compressed)',
' --source-comments Include debug info in output',
' --source-map Emit source map',
......@@ -56,12 +56,13 @@ var cli = meow({
'precision'
],
alias: {
c: 'source-comments',
i: 'indented-syntax',
o: 'output',
w: 'watch',
r: 'recursive',
x: 'omit-source-map-url',
c: 'source-comments',
r: 'recursive'
v: 'version',
w: 'watch'
},
default: {
'include-path': process.cwd(),
......
var fs = require('fs');
var eol = require('os').EOL,
fs = require('fs'),
package = require('../package.json');
/**
* Get Runtime Info
......@@ -35,5 +37,13 @@ function getBinaryIdentifiableName() {
v8SemVersion].join('');
}
function getSassInfo() {
return [
['node-sass', package.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', package.libsass, '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol);
}
process.runtime = getRuntimeInfo();
process.sassInfo = getSassInfo();
process.sassBinaryName = getBinaryIdentifiableName();
......@@ -259,11 +259,4 @@ module.exports.renderSync = function(options) {
* @api public
*/
module.exports.info = function() {
var package = require('../package.json');
return [
'node-sass version: ' + package.version,
'libsass version: ' + package.libsass
].join('\n');
};
module.exports.info = process.sassInfo;
......@@ -47,7 +47,7 @@
"cross-spawn": "^0.2.6",
"gaze": "^0.5.1",
"get-stdin": "^4.0.1",
"meow": "^3.0.0",
"meow": "^3.1.0",
"mkdirp": "^0.5.0",
"nan": "^1.6.2",
"npmconf": "^2.1.1",
......
......@@ -792,11 +792,16 @@ describe('api', function() {
});
describe('.info()', function() {
var package = require('../package.json'),
info = sass.info;
it('should return a correct version info', function(done) {
assert.equal(sass.info(), [
'node-sass version: ' + require('../package.json').version,
'libsass version: ' + require('../package.json').libsass
].join('\n'));
assert(info.indexOf(package.version) > 0);
assert(info.indexOf('(Wrapper)') > 0);
assert(info.indexOf('[JavaScript]') > 0);
assert(info.indexOf(package.libsass) > 0);
assert(info.indexOf('(Sass Compiler)') > 0);
assert(info.indexOf('[C/C++]') > 0);
done();
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment