Use ES6 in lib files.

This commit is contained in:
John-David Dalton
2016-08-27 08:32:48 -07:00
parent 5cc02555d0
commit 94750bfa3c
13 changed files with 150 additions and 154 deletions

View File

@@ -1,17 +1,17 @@
'use strict';
var async = require('async'),
path = require('path');
const async = require('async');
const path = require('path');
var file = require('../common/file'),
util = require('../common/util');
const file = require('../common/file');
const util = require('../common/util');
var basePath = path.join(__dirname, '..', '..'),
distPath = path.join(basePath, 'dist'),
filename = 'lodash.js';
const basePath = path.join(__dirname, '..', '..');
const distPath = path.join(basePath, 'dist');
const filename = 'lodash.js';
var baseLodash = path.join(basePath, filename),
distLodash = path.join(distPath, filename);
const baseLodash = path.join(basePath, filename);
const distLodash = path.join(distPath, filename);
/*----------------------------------------------------------------------------*/

View File

@@ -1,20 +1,20 @@
'use strict';
var _ = require('lodash'),
docdown = require('docdown'),
fs = require('fs-extra'),
path = require('path');
const _ = require('lodash');
const docdown = require('docdown');
const fs = require('fs-extra');
const path = require('path');
var util = require('../common/util');
const util = require('../common/util');
var basePath = path.join(__dirname, '..', '..'),
docPath = path.join(basePath, 'doc'),
readmePath = path.join(docPath, 'README.md');
const basePath = path.join(__dirname, '..', '..');
const docPath = path.join(basePath, 'doc');
const readmePath = path.join(docPath, 'README.md');
var pkg = require('../../package.json'),
version = pkg.version;
const pkg = require('../../package.json');
const version = pkg.version;
var config = {
const config = {
'base': {
'path': path.join(basePath, 'lodash.js'),
'title': '<a href="https://lodash.com/">lodash</a> <span>v' + version + '</span>',
@@ -74,8 +74,8 @@ function postprocess(markdown) {
* @param {string} type The format type.
*/
function build(type) {
var options = _.defaults({}, config.base, config[type]),
markdown = docdown(options);
const options = _.defaults({}, config.base, config[type]);
const markdown = docdown(options);
fs.writeFile(readmePath, postprocess(markdown), util.pitch);
}

View File

@@ -1,16 +1,16 @@
'use strict';
var _ = require('lodash'),
async = require('async'),
path = require('path');
const _ = require('lodash');
const async = require('async');
const path = require('path');
var file = require('../common/file'),
util = require('../common/util');
const file = require('../common/file');
const util = require('../common/util');
var basePath = path.join(__dirname, '..', '..'),
distPath = path.join(basePath, 'dist');
const basePath = path.join(__dirname, '..', '..');
const distPath = path.join(basePath, 'dist');
var filePairs = [
const filePairs = [
[path.join(distPath, 'lodash.core.js'), 'core.js'],
[path.join(distPath, 'lodash.core.min.js'), 'core.min.js'],
[path.join(distPath, 'lodash.min.js'), 'lodash.min.js']
@@ -25,9 +25,8 @@ var filePairs = [
* @param {string} target The output directory path.
*/
function build(target) {
var actions = _.map(filePairs, function(pair) {
return file.copy(pair[0], path.join(target, pair[1]));
});
const actions = _.map(filePairs, pair =>
file.copy(pair[0], path.join(target, pair[1])));
async.series(actions, util.pitch);
}

View File

@@ -1,41 +1,41 @@
'use strict';
var _ = require('lodash'),
fs = require('fs'),
marky = require('marky-markdown'),
path = require('path'),
util = require('../common/util');
const _ = require('lodash');
const fs = require('fs');
const marky = require('marky-markdown');
const path = require('path');
const util = require('../common/util');
var basePath = path.join(__dirname, '..', '..'),
docPath = path.join(basePath, 'doc'),
readmePath = path.join(docPath, 'README.md');
const basePath = path.join(__dirname, '..', '..');
const docPath = path.join(basePath, 'doc');
const readmePath = path.join(docPath, 'README.md');
const highlights = [
'comment',
'constant',
'delimiter',
'html',
'js',
'method',
'modifier',
'numeric',
'shell',
'source',
'string',
'text',
'type'
];
function build(type) {
var markdown = fs
const markdown = fs
// Load markdown.
.readFileSync(readmePath, 'utf8')
// Uncomment docdown HTML hints.
.replace(/(<)!--\s*|\s*--(>)/g, '$1$2');
var $ = marky(markdown, { 'sanitize': false }),
$header = $('h1').first().remove(),
version = _.trim($header.find('span').first().text()).slice(1);
var highlights = [
'comment',
'constant',
'delimiter',
'html',
'js',
'method',
'modifier',
'numeric',
'shell',
'source',
'string',
'text',
'type'
];
const $ = marky(markdown, { 'sanitize': false });
const $header = $('h1').first().remove();
const version = _.trim($header.find('span').first().text()).slice(1);
// Remove docdown horizontal rules.
$('hr').remove();
@@ -46,7 +46,7 @@ function build(type) {
.attr('id', null);
$(':header:not(h3) > a').each(function() {
var $a = $(this);
const $a = $(this);
$a.replaceWith($a.html());
});
@@ -54,8 +54,8 @@ function build(type) {
$('p:empty + h3').prev().remove();
$('h3 ~ p:empty').each(function() {
var $p = $(this),
node = this.previousSibling;
const $p = $(this);
let node = this.previousSibling;
while ((node = node.previousSibling) && node.name != 'h3' && node.name != 'p') {
$p.prepend(node.nextSibling);
@@ -63,19 +63,19 @@ function build(type) {
});
$('h3 code em').parent().each(function() {
var $code = $(this);
const $code = $(this);
$code.html($code.html().replace(/<\/?em>/g, '_'));
});
// Cleanup highlights class names.
$('.highlight [class]').each(function() {
var $el = $(this),
className = _.intersection($el.attr('class').split(/\s+/), highlights).join(' ');
const $el = $(this);
const className = _.intersection($el.attr('class').split(/\s+/), highlights).join(' ');
$el.attr('class', className || null);
});
var html = [
const html = [
// Append YAML front matter.
'---',
'id: docs',