Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Add JSHinting and EditorConfig #205

Merged
merged 11 commits into from
Jan 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
7 changes: 6 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"trailing": true,
"undef": true,
"unused": true,
"expr":true
"expr":true,
"multistr": true,
"globals": {
"it": true,
"describe": true
}
}
144 changes: 72 additions & 72 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
#!/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+ '`');
}
14 changes: 7 additions & 7 deletions examples/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
console.log('server listening on port 3000');
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"scripts": {
"install": "node build.js",
"test": "mocha test",
"pretest": "jshint .",
"prepublish": "bash scripts/prepublish.sh"
},
"bin": {
Expand All @@ -42,5 +43,8 @@
"mocha": "1.13.x",
"chalk": "~0.3.0",
"nan": "~0.6.0"
},
"devDependencies": {
"jshint": "~2.4.0"
}
}
14 changes: 7 additions & 7 deletions sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
16 changes: 0 additions & 16 deletions test.js

This file was deleted.

10 changes: 4 additions & 6 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -139,5 +138,4 @@ describe('cli', function() {
});
});


});
32 changes: 0 additions & 32 deletions test/source_comments_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand All @@ -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({
Expand Down
Loading