Commit 10018d90 by Nick Schonning

Merge pull request #205 from nschonni/jshinting

Add JSHinting and EditorConfig
parents f4cb0f4e bf2e9293
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = spaces
indent_size = 2
node_modules/
\ No newline at end of file
......@@ -6,5 +6,10 @@
"trailing": true,
"undef": true,
"unused": true,
"expr":true
"expr":true,
"multistr": true,
"globals": {
"it": true,
"describe": true
}
}
\ No newline at end of file
#!/usr/bin/env node
var cp = require('child_process'),
fs = require('fs'),
path = require('path'),
Mocha = require('mocha');
fs = require('fs'),
path = require('path'),
Mocha = require('mocha');
// Parse args
var force = false, debug = false;
var arch = process.arch,
platform = process.platform,
v8 = /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0];
platform = process.platform,
v8 = /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0];
var args = process.argv.slice(2).filter(function(arg) {
if (arg === '-f') {
force = true;
return false;
} else if (arg.substring(0, 13) === '--target_arch') {
arch = arg.substring(14);
} else if (arg === '--debug') {
debug = true;
}
return true;
if (arg === '-f') {
force = true;
return false;
} else if (arg.substring(0, 13) === '--target_arch') {
arch = arg.substring(14);
} else if (arg === '--debug') {
debug = true;
}
return true;
});
if (!{ia32: true, x64: true, arm: true}.hasOwnProperty(arch)) {
console.error('Unsupported (?) architecture: `'+ arch+ '`');
process.exit(1);
console.error('Unsupported (?) architecture: `'+ arch+ '`');
process.exit(1);
}
// Test for pre-built library
var modPath = platform + '-' + arch + '-v8-' + v8;
if (!force && !process.env.SKIP_NODE_SASS_TESTS) {
try {
fs.statSync(path.join(__dirname, 'bin', modPath, 'binding.node'));
console.log('`'+ modPath+ '` exists; testing');
var mocha = new Mocha({
reporter: 'dot',
ui: 'bdd',
timeout: 999999
});
mocha.addFile(path.resolve(__dirname, "test", "test.js"));
try {
fs.statSync(path.join(__dirname, 'bin', modPath, 'binding.node'));
console.log('`'+ modPath+ '` exists; testing');
var runner = mocha.run(function (done) {
if (done !== 0) {
console.log('Problem with the binary; manual build incoming');
console.log('Please consider contributing the release binary to https://github.com/andrew/node-sass-binaries for npm distribution.');
build();
} else {
console.log('Binary is fine; exiting');
}
});
} catch (ex) {
// Stat failed
build();
}
var mocha = new Mocha({
reporter: 'dot',
ui: 'bdd',
timeout: 999999
});
mocha.addFile(path.resolve(__dirname, "test", "test.js"));
mocha.run(function (done) {
if (done !== 0) {
console.log('Problem with the binary; manual build incoming');
console.log('Please consider contributing the release binary to https://github.com/andrew/node-sass-binaries for npm distribution.');
build();
} else {
console.log('Binary is fine; exiting');
}
});
} catch (ex) {
// Stat failed
build();
}
} else {
build();
build();
}
// Build it
function build() {
cp.spawn(
process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp',
['rebuild'].concat(args),
{customFds: [0, 1, 2]})
.on('exit', function(err) {
if (err) {
if (err === 127) {
console.error(
'node-gyp not found! Please upgrade your install of npm! You need at least 1.1.5 (I think) '+
'and preferably 1.1.30.'
);
} else {
console.error('Build failed');
}
return process.exit(err);
}
afterBuild();
});
cp.spawn(
process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp',
['rebuild'].concat(args),
{customFds: [0, 1, 2]})
.on('exit', function(err) {
if (err) {
if (err === 127) {
console.error(
'node-gyp not found! Please upgrade your install of npm! You need at least 1.1.5 (I think) '+
'and preferably 1.1.30.'
);
} else {
console.error('Build failed');
}
return process.exit(err);
}
afterBuild();
});
}
// Move it to expected location
function afterBuild() {
var targetPath = path.join(__dirname, 'build', debug ? 'Debug' : 'Release', 'binding.node');
var installPath = path.join(__dirname, 'bin', modPath, 'binding.node');
var targetPath = path.join(__dirname, 'build', debug ? 'Debug' : 'Release', 'binding.node');
var installPath = path.join(__dirname, 'bin', modPath, 'binding.node');
try {
fs.mkdirSync(path.join(__dirname, 'bin', modPath));
} catch (ex) {}
try {
fs.mkdirSync(path.join(__dirname, 'bin', modPath));
} catch (ex) {}
try {
fs.statSync(targetPath);
} catch (ex) {
console.error('Build succeeded but target not found');
process.exit(1);
}
fs.renameSync(targetPath, installPath);
console.log('Installed in `'+ installPath+ '`');
try {
fs.statSync(targetPath);
} catch (ex) {
console.error('Build succeeded but target not found');
process.exit(1);
}
fs.renameSync(targetPath, installPath);
console.log('Installed in `'+ installPath+ '`');
}
......@@ -3,21 +3,21 @@
* Module dependencies.
*/
var connect = require('connect')
, sass = require('../sass');
var connect = require('connect'),
sass = require('../sass');
// Setup server
// $ curl http://localhost:3000/test.css
var server = connect.createServer(
sass.middleware({
src: __dirname
, dest: __dirname + '/public'
, debug: true
, outputStyle: 'compressed'
src: __dirname,
dest: __dirname + '/public',
debug: true,
outputStyle: 'compressed'
}),
connect.static(__dirname + '/public')
);
server.listen(3000);
console.log('server listening on port 3000');
\ No newline at end of file
console.log('server listening on port 3000');
......@@ -26,6 +26,7 @@
"scripts": {
"install": "node build.js",
"test": "mocha test",
"pretest": "jshint .",
"prepublish": "bash scripts/prepublish.sh"
},
"bin": {
......@@ -42,5 +43,8 @@
"mocha": "1.13.x",
"chalk": "~0.3.0",
"nan": "~0.6.0"
},
"devDependencies": {
"jshint": "~2.4.0"
}
}
......@@ -24,14 +24,14 @@ var SASS_OUTPUT_STYLE = {
expanded: 1,
compact: 2,
compressed: 3
};
};
var SASS_SOURCE_COMMENTS = {
none: 0,
// This is called default in libsass, but is a reserved keyword here
normal: 1,
map: 2
};
none: 0,
// This is called default in libsass, but is a reserved keyword here
normal: 1,
map: 2
};
var prepareOptions = function(options) {
var paths, style, comments;
......@@ -52,7 +52,7 @@ var deprecatedRender = function(css, callback, options) {
var errCallback = function(err) {
callback(err);
};
var oldCallback = function(css, err) {
var oldCallback = function(css) {
callback(null, css);
};
return binding.render(css, oldCallback, errCallback, options.paths.join(':'), options.style, options.comments);
......
var sass = require('./sass');
var scssStr = '#navbar {\
width: 80%;\
height: 23px; }\
#navbar ul {\
list-style-type: none; }\
#navbar li {\
float: left;\
a {\
font-weight: bold; }}';
sass.render(scssStr, function(err, css){
console.log(css)
})
......@@ -2,7 +2,6 @@ var path = require('path'),
assert = require('assert'),
fs = require('fs'),
exec = require('child_process').exec,
sass = require('../sass'),
cli = require('../lib/cli'),
cliPath = path.resolve(__dirname, '../bin/node-sass'),
......@@ -37,7 +36,7 @@ describe('cli', function() {
exec('node ' + cliPath + ' ' + sampleFilename, {
cwd: __dirname
}, function(err, stdout, stderr) {
}, function() {
fs.exists(resultPath, function(exists) {
assert(exists);
......@@ -46,12 +45,12 @@ describe('cli', function() {
});
});
it('should compile sample.scss to ../out.css', function(done) {
it('should compile sample.scss to ../out.css', function(done) {
var resultPath = path.resolve(__dirname, '../out.css');
exec('node ' + cliPath + ' ' + sampleFilename + ' ../out.css', {
cwd: __dirname
}, function(err, stdout, stderr) {
}, function() {
fs.exists(resultPath, function(exists) {
assert(exists);
......@@ -95,7 +94,7 @@ describe('cli', function() {
var resultPath = path.join(__dirname, '../output.css');
var emitter = cli(['--output', resultPath, path.join(__dirname, 'sample.scss')]);
emitter.on('error', done);
emitter.on('write', function(err, file, css){
emitter.on('write', function(){
fs.exists(resultPath, function(exists) {
assert(exists);
fs.unlink(resultPath, done);
......@@ -139,5 +138,4 @@ describe('cli', function() {
});
});
});
......@@ -4,21 +4,6 @@ var assert = require('assert');
var sampleFilename = require('path').resolve(__dirname, 'sample.scss');
var scssStr = '#navbar {\
width: 80%;\
height: 23px; }\
#navbar ul {\
list-style-type: none; }\
#navbar li {\
float: left;\
a {\
font-weight: bold; }}\
@mixin keyAnimation($name, $attr, $value) {\
@-webkit-keyframes #{$name} {\
0% { #{$attr}: $value; }\
}\
}';
var expectedCommentsScssStr = '/* line 1, ' + sampleFilename + ' */\n\
#navbar {\n\
width: 80%;\n\
......@@ -35,23 +20,6 @@ var expectedCommentsScssStr = '/* line 1, ' + sampleFilename + ' */\n\
#navbar li a {\n\
font-weight: bold; }\n';
var expectedDebugScssStr = '@media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\000031}}\n\
#navbar {\n\
width: 80%;\n\
height: 23px; }\n\
\n\
@media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\000035}}\n\
#navbar ul {\n\
list-style-type: none; }\n\
\n\
@media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\000038}}\n\
#navbar li {\n\
float: left; }\n\
@media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\0000310}}\n\
#navbar li a {\n\
font-weight: bold; }\n';
describe("compile file with source comments", function() {
it("should compile with render and comment outputs", function(done) {
sass.render({
......
......@@ -38,7 +38,7 @@ var expectedRender = '#navbar {\n\
describe("DEPRECATED: compile scss", function() {
it("should compile with render", function(done) {
sass.render(scssStr, function(err, css) {
sass.render(scssStr, function(err) {
done(err);
});
});
......@@ -98,6 +98,7 @@ describe("compile scss", function() {
sass.render({
data: '{zzz}',
success: function(css) {
console.log(css);
},
error: function(error, status) {
assert.equal(status, 1);
......@@ -128,7 +129,7 @@ describe("compile file with include paths", function(){
error: function (error) {
done(error);
}
})
});
});
});
......@@ -145,7 +146,7 @@ describe("compile file", function() {
});
});
it("should compile with renderSync", function(done) {
it("should compile with renderSync", function(done) {
done(assert.ok(sass.renderSync({file: sampleFilename})));
});
......
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