diff --git a/Gruntfile.js b/Gruntfile.js index 8caa6cb0..ff09d0fe 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -49,30 +49,22 @@ module.exports = function(grunt) { }, browserify: { - dist: { - files: { - 'dist/less.js': ['lib/less/browser.js'] - } - }, - browsertest: { - files: { - 'test/browser/less.js': ['lib/less/browser.js'] - } + browser: { + src: ['./lib/less/browser.js'], + dest: 'tmp/less.js' } }, concat: { options: { stripBanners: 'all', - banner: '<%= meta.banner %>\n\n(function (window, undefined) {', - footer: '\n})(window);' + banner: '<%= meta.banner %>' }, - // Browser versions browsertest: { - src: ['<%= build.browser %>'], + src: '<%= browserify.browser.dest %>', dest: 'test/browser/less.js' }, - stable: { - src: ['<%= build.browser %>'], + dist: { + src: '<%= browserify.browser.dest %>', dest: 'dist/less.js' }, // Rhino @@ -107,8 +99,8 @@ module.exports = function(grunt) { banner: '<%= meta.banner %>', mangle: true }, - stable: { - src: ['<%= concat.stable.dest %>'], + dist: { + src: ['<%= concat.dist.dest %>'], dest: 'dist/less.min.js' } }, @@ -118,7 +110,8 @@ module.exports = function(grunt) { files: { src: [ 'Gruntfile.js', - 'lib/less/**/*.js' + 'lib/less/**/*.js', + 'bin/lessc' ] } }, @@ -257,37 +250,46 @@ module.exports = function(grunt) { 'test' ]); + grunt.registerTask('updateBowerJson', function() { + var bowerJson = require('./bower.json'); + bowerJson.version = grunt.config('pkg.version'); + fs.writeFileSync('./bower.json', JSON.stringify(bowerJson,null,2)); + }); + // Release - grunt.registerTask('stable', [ - 'concat:stable', - 'uglify:stable', + grunt.registerTask('dist', [ + 'browserify:browser', + 'concat:dist', + 'uglify:dist', 'updateBowerJson' ]); // Release Rhino Version grunt.registerTask('rhino', [ + 'browserify:rhino', 'concat:rhino', 'concat:rhinolessc' ]); - - // Run all browser tests + + // Create the browser version of less.js + grunt.registerTask('browsertest-lessjs', [ + 'browserify:browser', + 'concat:browsertest' + ]); + + // Run all browser tests grunt.registerTask('browsertest', [ - 'browser', + 'browsertest-lessjs', 'connect', 'jasmine' ]); // setup a web server to run the browser tests in a browser rather than phantom grunt.registerTask('browsertest-server', [ - 'browser', + 'browsertest-less', 'shell:browsertest-server' ]); - // Create the browser version of less.js - grunt.registerTask('browser', [ - 'browserify:browsertest' - ]); - // Run all tests grunt.registerTask('test', [ 'clean', @@ -312,9 +314,4 @@ module.exports = function(grunt) { 'concat:readme' ]); - grunt.registerTask('updateBowerJson', function() { - var bowerJson = require('./bower.json'); - bowerJson.version = grunt.config('pkg.version'); - fs.writeFileSync('./bower.json', JSON.stringify(bowerJson,null,2)); - }); }; diff --git a/bin/lessc b/bin/lessc index c1abb78f..16620aab 100755 --- a/bin/lessc +++ b/bin/lessc @@ -35,7 +35,7 @@ var continueProcessing = true, // calling process.exit does not flush stdout always // so use this to set the exit code -process.on('exit', function() { process.reallyExit(currentErrorcode) }); +process.on('exit', function() { process.reallyExit(currentErrorcode); }); var checkArgFunc = function(arg, option) { if (!option) { @@ -67,19 +67,22 @@ var sourceMapFileInline = false; args = args.filter(function (arg) { var match; - if (match = arg.match(/^-I(.+)$/)) { + match = arg.match(/^-I(.+)$/); + if (match) { options.paths.push(match[1]); return false; } - if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i)) { arg = match[1] } - else { return arg } + match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i); + if (match) { arg = match[1]; } + else { return arg; } switch (arg) { case 'v': case 'version': console.log("lessc " + less.version.join('.') + " (Less Compiler) [JavaScript]"); continueProcessing = false; + break; case 'verbose': options.verbose = true; break; @@ -98,6 +101,7 @@ args = args.filter(function (arg) { case 'help': require('../lib/less/lessc_helper').printUsage(); continueProcessing = false; + break; case 'x': case 'compress': options.compress = true; @@ -257,7 +261,6 @@ if (!continueProcessing) { } var input = args[1]; -var inputbase = args[1]; if (input && input != '-') { input = path.resolve(process.cwd(), input); } @@ -345,12 +348,14 @@ var parseLessFile = function (e, data) { return; } else if (options.depends) { for(var file in parser.imports.files) { - sys.print(file + " ") + if (parser.imports.files.hasOwnProperty(file)) { + sys.print(file + " "); + } } sys.print("\n"); } else { try { - if (options.lint) { writeSourceMap = function() {} } + if (options.lint) { writeSourceMap = function() {}; } var css = tree.toCSS({ silent: options.silent, verbose: options.verbose, @@ -380,7 +385,7 @@ var parseLessFile = function (e, data) { } } else { sys.print(css); - } + } } } catch (e) { less.writeError(e, options); diff --git a/build/build.yml b/build/build.yml index 098901e4..c179f936 100644 --- a/build/build.yml +++ b/build/build.yml @@ -19,12 +19,10 @@ lib_source_map: 'lib/source-map' # General # ================================= prepend: - browser: ['build/require.js', 'build/browser-header.js'] rhino: ['build/require-rhino.js', 'build/rhino-header.js', 'build/rhino-modules.js'] append: amd: build/amd.js - browser: ['lib/less/environments/browser.js', '<%= build.lib %>/browser.js'] rhino: <%= build.lib %>/rhino.js @@ -48,36 +46,6 @@ less: browser : <%= build.lib %>/browser.js source_map_output: <%= build.lib %>/source-map-output.js - -# ================================= -# Browser build -# ================================= - -# <%= build.browser %> -browser: - - # prepend utils - - <%= build.prepend.browser %> - - # core - - <%= build.less.parser %> - - <%= build.less.functions %> - - <%= build.less.colors %> - - <%= build.less.tree %> - - <%= build.less.treedir %> # glob all files - - <%= build.less.env %> - - <%= build.less.visitor %> - - <%= build.less.import_visitor %> - - <%= build.less.join %> - - <%= build.less.to_css_visitor %> - - <%= build.less.extend_visitor %> - - <%= build.less.source_map_output %> - - # append browser-specific code - - <%= build.append.browser %> - - <%= build.append.amd %> - - # ================================= # Rhino build # =================================