Commit 043c5670 by Marcin Cieslak

Use runtime libsass version

Return real libsass version
information - in when a shared library
is used this version may be changed
even without recompilation

libsass version in the package.json
file is now used only for checking
out the bundled libsass library
from the git submodule
parent 2fce3035
...@@ -354,7 +354,7 @@ console.log(result.stats); ...@@ -354,7 +354,7 @@ console.log(result.stats);
### Version information (>= v2.0.0) ### Version information (>= v2.0.0)
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 exposed via the `info` method:
```javascript ```javascript
var sass = require('node-sass'); var sass = require('node-sass');
...@@ -369,6 +369,8 @@ console.log(sass.info); ...@@ -369,6 +369,8 @@ console.log(sass.info);
*/ */
``` ```
Since node-sass >=v3.0.0 libsass version is determined at run time.
## Integrations ## Integrations
Listing of community uses of node-sass in build tools and frameworks. Listing of community uses of node-sass in build tools and frameworks.
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
'<!(node -e "require(\'nan\')")', '<!(node -e "require(\'nan\')")',
], ],
'conditions': [ 'conditions': [
['libsass_ext == ""', { ['libsass_ext == "" or libsass_ext == "no"', {
'dependencies': [ 'dependencies': [
'src/libsass.gyp:libsass', 'src/libsass.gyp:libsass',
] ]
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
* node-sass: lib/extensions.js * node-sass: lib/extensions.js
*/ */
var eol = require('os').EOL, var flags = {},
flags = {},
fs = require('fs'), fs = require('fs'),
package = require('../package.json'), package = require('../package.json'),
path = require('path'); path = require('path');
...@@ -109,18 +108,6 @@ function getBinaryUrl() { ...@@ -109,18 +108,6 @@ function getBinaryUrl() {
return [site, 'v' + package.version, sass.binaryName].join('/'); return [site, 'v' + package.version, sass.binaryName].join('/');
} }
/**
* Get Sass version information
*
* @api private
*/
function getVersionInfo() {
return [
['node-sass', package.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', package.libsass, '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol);
}
collectArguments(process.argv.slice(2)); collectArguments(process.argv.slice(2));
...@@ -129,7 +116,6 @@ var sass = process.sass = {}; ...@@ -129,7 +116,6 @@ var sass = process.sass = {};
sass.binaryName = getBinaryName(); sass.binaryName = getBinaryName();
sass.binaryUrl = getBinaryUrl(); sass.binaryUrl = getBinaryUrl();
sass.runtime = getRuntimeInfo(); sass.runtime = getRuntimeInfo();
sass.versionInfo = getVersionInfo();
/** /**
* Get binary path. * Get binary path.
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
* node-sass: lib/index.js * node-sass: lib/index.js
*/ */
var path = require('path'), var eol = require('os').EOL,
util = require('util'); path = require('path'),
util = require('util'),
package = require('../package.json');
require('./extensions'); require('./extensions');
...@@ -14,6 +16,19 @@ require('./extensions'); ...@@ -14,6 +16,19 @@ require('./extensions');
var binding = require(process.sass.getBinaryPath(true)); var binding = require(process.sass.getBinaryPath(true));
/** /**
* Get Sass version information
*
* @api private
*/
function getVersionInfo(binding) {
return [
['node-sass', package.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', binding.libsassVersion(), '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol);
}
/**
* Get input file * Get input file
* *
* @param {Object} options * @param {Object} options
...@@ -400,6 +415,7 @@ module.exports.renderSync = function(options) { ...@@ -400,6 +415,7 @@ module.exports.renderSync = function(options) {
* @api public * @api public
*/ */
process.sass.versionInfo = getVersionInfo(binding);
module.exports.info = process.sass.versionInfo; module.exports.info = process.sass.versionInfo;
/** /**
......
...@@ -302,11 +302,17 @@ NAN_METHOD(render_file_sync) { ...@@ -302,11 +302,17 @@ NAN_METHOD(render_file_sync) {
NanReturnValue(NanNew<Boolean>(result == 0)); NanReturnValue(NanNew<Boolean>(result == 0));
} }
NAN_METHOD(libsass_version) {
NanScope();
NanReturnValue(NanNew<String>(libsass_version()));
}
void RegisterModule(v8::Handle<v8::Object> target) { void RegisterModule(v8::Handle<v8::Object> target) {
NODE_SET_METHOD(target, "render", render); NODE_SET_METHOD(target, "render", render);
NODE_SET_METHOD(target, "renderSync", render_sync); NODE_SET_METHOD(target, "renderSync", render_sync);
NODE_SET_METHOD(target, "renderFile", render_file); NODE_SET_METHOD(target, "renderFile", render_file);
NODE_SET_METHOD(target, "renderFileSync", render_file_sync); NODE_SET_METHOD(target, "renderFileSync", render_file_sync);
NODE_SET_METHOD(target, "libsassVersion", libsass_version);
SassTypes::Factory::initExports(target); SassTypes::Factory::initExports(target);
} }
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
{ {
'target_name': 'libsass', 'target_name': 'libsass',
'type': 'static_library', 'type': 'static_library',
'defines': [
'LIBSASS_VERSION="<!(node -e "process.stdout.write(require(\'../package.json\').libsass)")"'
],
'sources': [ 'sources': [
'libsass/ast.cpp', 'libsass/ast.cpp',
'libsass/base64vlq.cpp', 'libsass/base64vlq.cpp',
...@@ -52,7 +55,7 @@ ...@@ -52,7 +55,7 @@
], ],
'cflags_cc': [ 'cflags_cc': [
'-fexceptions', '-fexceptions',
'-frtti' '-frtti',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'include_dirs': [ 'libsass' ], 'include_dirs': [ 'libsass' ],
......
...@@ -1410,7 +1410,7 @@ describe('api', function() { ...@@ -1410,7 +1410,7 @@ describe('api', function() {
assert(info.indexOf(package.version) > 0); assert(info.indexOf(package.version) > 0);
assert(info.indexOf('(Wrapper)') > 0); assert(info.indexOf('(Wrapper)') > 0);
assert(info.indexOf('[JavaScript]') > 0); assert(info.indexOf('[JavaScript]') > 0);
assert(info.indexOf(package.libsass) > 0); assert(info.indexOf('[NA]') < 0);
assert(info.indexOf('(Sass Compiler)') > 0); assert(info.indexOf('(Sass Compiler)') > 0);
assert(info.indexOf('[C/C++]') > 0); assert(info.indexOf('[C/C++]') > 0);
......
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