Skip to content

Commit

Permalink
ES2015ify
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 9, 2017
1 parent 90b1628 commit 0a43ad1
Show file tree
Hide file tree
Showing 20 changed files with 286 additions and 459 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
121 changes: 0 additions & 121 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
*.js text eol=lf
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
sudo: false
language: node_js
node_js:
- v6
- v5
- v4
- '6'
- '4'
before_script:
- export NODE_PATH="$NVM_PATH/../node_modules"
env:
Expand Down
8 changes: 4 additions & 4 deletions benchmark/env.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*global suite, bench */
/* global suite, bench */
'use strict';
var yeoman = require('..');
const yeoman = require('..');

suite('Environment', function () {
bench('#lookup()', function (done) {
suite('Environment', () => {
bench('#lookup()', done => {
yeoman.createEnv().lookup(done);
});
});
56 changes: 20 additions & 36 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,34 @@
'use strict';
var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');

gulp.task('static', function () {
return gulp.src('**/*.js')
.pipe(excludeGitignore())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
const path = require('path');
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const istanbul = require('gulp-istanbul');
const nsp = require('gulp-nsp');
const plumber = require('gulp-plumber');
const coveralls = require('gulp-coveralls');

gulp.task('nsp', cb => {
nsp({package: path.resolve('package.json')}, cb);
});

gulp.task('pre-test', function () {
return gulp.src('lib/**/*.js')
gulp.task('pre-test', () =>
gulp.src('lib/**/*.js')
.pipe(istanbul({
includeUntested: true
}))
.pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
var mochaErr;
.pipe(istanbul.hookRequire())
);

gulp.task('test', ['pre-test'], () =>
gulp.src('test/*.js')
.pipe(plumber())
.pipe(mocha({reporter: 'spec'}))
.on('error', function (err) {
mochaErr = err;
})
.pipe(mocha({
reporter: 'spec'
}))
.pipe(istanbul.writeReports())
.on('end', function () {
cb(mochaErr);
});
});
);

gulp.task('coveralls', ['test'], function () {
gulp.task('coveralls', ['test'], () => {
if (!process.env.CI) {
return;
}
Expand All @@ -54,4 +38,4 @@ gulp.task('coveralls', ['test'], function () {
});

gulp.task('prepublish', ['nsp']);
gulp.task('default', ['static', 'test', 'coveralls']);
gulp.task('default', ['test', 'coveralls']);
25 changes: 11 additions & 14 deletions lib/adapter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

var _ = require('lodash');
var inquirer = require('inquirer');
var diff = require('diff');
var chalk = require('chalk');
var logger = require('./util/log');
const _ = require('lodash');
const inquirer = require('inquirer');
const diff = require('diff');
const chalk = require('chalk');
const logger = require('./util/log');

/**
* `TerminalAdapter` is the default implementation of `Adapter`, an abstraction
Expand All @@ -14,16 +13,14 @@ var logger = require('./util/log');
*
* @constructor
*/
var TerminalAdapter = module.exports = function TerminalAdapter() {
const TerminalAdapter = module.exports = function TerminalAdapter() {
this.promptModule = inquirer.createPromptModule();
};

TerminalAdapter.prototype._colorDiffAdded = chalk.black.bgGreen;
TerminalAdapter.prototype._colorDiffRemoved = chalk.bgRed;
TerminalAdapter.prototype._colorLines = function colorLines(name, str) {
return str.split('\n').map(function (line) {
return this['_colorDiff' + name](line);
}, this).join('\n');
return str.split('\n').map(line => this[`_colorDiff${name}`](line)).join('\n');
};

/**
Expand All @@ -47,7 +44,7 @@ TerminalAdapter.prototype.prompt = function () {};
* @param {string} expected
*/
TerminalAdapter.prototype.diff = function _diff(actual, expected) {
var msg = diff.diffLines(actual, expected).map(function (str) {
let msg = diff.diffLines(actual, expected).map(str => {
if (str.added) {
return this._colorLines('Added', str.value);
}
Expand All @@ -57,9 +54,9 @@ TerminalAdapter.prototype.diff = function _diff(actual, expected) {
}

return str.value;
}, this).join('');
}).join('');

// legend
// Legend
msg = '\n' +
this._colorDiffRemoved('removed') +
' ' +
Expand All @@ -79,7 +76,7 @@ TerminalAdapter.prototype.diff = function _diff(actual, expected) {
TerminalAdapter.prototype.log = logger();

TerminalAdapter.prototype.prompt = function (questions, cb) {
var promise = this.promptModule(questions);
const promise = this.promptModule(questions);
promise.then(cb || _.noop);
return promise;
};
Loading

0 comments on commit 0a43ad1

Please sign in to comment.