diff options
author | Johann-S <johann.servoire@gmail.com> | 2017-11-21 12:01:19 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2017-11-22 14:35:49 +0300 |
commit | f62a1fbe4835f177530c2c38fe29db554823e711 (patch) | |
tree | 0d59a294a20ef891abf0f43bd748416e38a560c8 /build | |
parent | 4ca78706a6cee176252a3ae0839a66ba5582b0f2 (diff) |
ES6-ify our node.js scripts.
Diffstat (limited to 'build')
-rw-r--r-- | build/phantom.js | 22 | ||||
-rw-r--r-- | build/stamp.js | 36 |
2 files changed, 27 insertions, 31 deletions
diff --git a/build/phantom.js b/build/phantom.js index 6b81ab8..469e866 100644 --- a/build/phantom.js +++ b/build/phantom.js @@ -1,30 +1,32 @@ -/* eslint-env node */ +/* eslint-env node, es6 */ 'use strict'; -var os = require('os'); -var glob = require('glob'); -var async = require('async'); -var qunit = require('node-qunit-phantomjs'); +const os = require('os'); +const glob = require('glob'); +const async = require('async'); +const qunit = require('node-qunit-phantomjs'); -var THREADS = os.cpus().length <= 2 ? 1 : os.cpus().length / 2; +const cpus = os.cpus().length; +const THREADS = cpus <= 2 ? 1 : cpus / 2; -var ignores = [ +const ignore = [ 'test/fixtures/jquery/missing.html', 'test/fixtures/jquery/and_bs_js_both_missing.html', 'test/fixtures/charset/not-utf8.html' ]; -glob('test/fixtures/**/*.html', {ignore: ignores}, function (err, files) { +glob('test/fixtures/**/*.html', {ignore}, (err, files) => { if (err) { throw err; } async.eachLimit(files, THREADS, - function (file, callback) { + (file, callback) => { qunit(file, {timeout: 10}, callback); - }, function (er) { + }, + (er) => { if (er) { throw er; } diff --git a/build/stamp.js b/build/stamp.js index c150f27..80a104a 100644 --- a/build/stamp.js +++ b/build/stamp.js @@ -1,28 +1,22 @@ -/* This file is taken from <https://github.com/twbs/bootstrap/blob/v4-dev/build/stamp.js> - and adapted for Bootlint. - */ +// This file is taken from Bootstrap and adapted for Bootlint. -/* eslint-env node */ +/* eslint-env node, es6 */ 'use strict'; -var fs = require('fs'); - -fs.readFile('package.json', function (err, data) { - if (err) { - throw err; - } +const path = require('path'); +const pkg = require(path.resolve('package.json')); +const year = new Date().getFullYear(); - var pkg = JSON.parse(data); - var year = new Date().getFullYear(); - - var stampTop = '/*!\n * Bootlint v' + pkg.version + ' (' + pkg.homepage + ')\n' + - ' * ' + pkg.description + '\n' + - ' * Copyright (c) 2014-' + year + ' The Bootlint Authors\n' + - ' * Licensed under the MIT License (https://github.com/twbs/bootlint/blob/master/LICENSE).\n' + - ' */\n'; +const stampTop = +`/*! + * Bootlint v${pkg.version} (${pkg.homepage}) + * ${pkg.description} + * Copyright (c) 2014-${year} The Bootlint Authors + * Licensed under the MIT License (https://github.com/twbs/bootlint/blob/master/LICENSE). + */ - process.stdout.write(stampTop); +`; - process.stdin.pipe(process.stdout); -}); +process.stdout.write(stampTop); +process.stdin.pipe(process.stdout); |