Skip to content
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.

Commit

Permalink
Always include Babel
Browse files Browse the repository at this point in the history
Because we are modern baby!
  • Loading branch information
sondr3 committed May 17, 2017
1 parent 4cd7b00 commit 72b1572
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 100 deletions.
16 changes: 1 addition & 15 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ module.exports = class extends Generator {
constructor(args, options) {
super(args, options);

this.option('babel', {
type: Boolean,
required: false,
desc: 'Compile your JS with Babel'
});

this.option('readme', {
type: String,
required: false,
Expand Down Expand Up @@ -56,12 +50,6 @@ module.exports = class extends Generator {
name: 'authorEmail',
message: "What's your email?",
store: true
},
{
name: 'babel',
type: 'confirm',
message: 'Compile your JS with Babel?',
when: this.options.babel === undefined
}
];

Expand Down Expand Up @@ -92,9 +80,7 @@ module.exports = class extends Generator {

this.composeWith(require.resolve('../git'));

this.composeWith(require.resolve('../gulp'), {
babel: this.props.babel
});
this.composeWith(require.resolve('../gulp'));

this.composeWith(require.resolve('../readme'), {
projectName: this.props.projectName,
Expand Down
34 changes: 0 additions & 34 deletions generators/gulp/babel.test.js

This file was deleted.

36 changes: 3 additions & 33 deletions generators/gulp/gulp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ describe('generator-statisk -- no babel', () => {
return helpers.run(path.join(__dirname, '.')).withOptions({
name: pkg.name,
version: pkg.version,
'skip-install': true,
babel: false
'skip-install': true
});
});

Expand Down Expand Up @@ -71,9 +70,11 @@ describe('generator-statisk -- no babel', () => {
assert.jsonFileContent('package.json', {
devDependencies: {
autoprefixer: '^6.2.3',
'babel-preset-es2015': '^6.9.0',
'browser-sync': '^2.11.0',
del: '^2.2.0',
gulp: 'git://github.com/gulpjs/gulp.git#4.0',
'gulp-babel': '^6.1.2',
'gulp-cache': '^0.4.1',
'gulp-concat': '^2.6.0',
'gulp-cssnano': '^2.1.0',
Expand All @@ -97,34 +98,3 @@ describe('generator-statisk -- no babel', () => {
});
});
});

describe('generator-statisk -- with babel', () => {
beforeAll(() => {
const pkg = require('../../package.json');

return helpers.run(require.resolve('.')).withOptions({
name: pkg.name,
version: pkg.version,
'skip-install': true,
babel: true
});
});

test('creates gulpfile', () => {
assert.file('gulpfile.js');
});

test('package.json contains babel packages', () => {
assert.jsonFileContent('package.json', {
devDependencies: {
'gulp-babel': '^6.1.2',
'babel-preset-es2015': '^6.9.0'
}
});
});

test('gulpfile contains babel', () => {
assert.fileContent('gulpfile.js', 'babel');
assert.fileContent('gulpfile.js', 'es2015');
})
});
19 changes: 3 additions & 16 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ module.exports = class extends Generator {
constructor(args, options) {
super(args, options);

this.option('babel', {
type: Boolean,
required: true
});

this.option('name', {
type: String,
required: true,
Expand All @@ -36,9 +31,11 @@ module.exports = class extends Generator {
pkg.devDependencies = pkg.devDependencies || {};
_.extend(pkg.devDependencies, {
autoprefixer: '^6.2.3',
'babel-preset-es2015': '^6.9.0',
'browser-sync': '^2.11.0',
del: '^2.2.0',
gulp: 'git://github.com/gulpjs/gulp.git#4.0',
'gulp-babel': '^6.1.2',
'gulp-cache': '^0.4.1',
'gulp-concat': '^2.6.0',
'gulp-cssnano': '^2.1.0',
Expand All @@ -60,15 +57,6 @@ module.exports = class extends Generator {
yargs: '^5.0.0'
});

if (this.options.babel) {
_.merge(pkg, {
devDependencies: {
'gulp-babel': '^6.1.2',
'babel-preset-es2015': '^6.9.0'
}
});
}

this.fs.writeJSON(this.destinationPath('package.json'), pkg);

this.fs.copyTpl(
Expand All @@ -78,8 +66,7 @@ module.exports = class extends Generator {
date: new Date().toISOString().split('T')[0],
name: this.options.name,
version: this.options.version,
buildContent: this.options.buildContent,
babel: this.options.babel
buildContent: this.options.buildContent
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions generators/gulp/templates/gulpfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ gulp.task('scripts', () =>
'src/assets/javascript/main.js'
])
.pipe($.newer('.tmp/assets/javascript/index.js', {dest: '.tmp/assets/javascript', ext: '.js'}))
.pipe($.if(!argv.prod, $.sourcemaps.init()))<% if (babel) { %>
.pipe($.if(!argv.prod, $.sourcemaps.init()))
.pipe($.babel({
presets: ['es2015']
}))<% } %>
}))
.pipe($.concat('index.js'))
.pipe($.size({
showFiles: true
Expand Down

0 comments on commit 72b1572

Please sign in to comment.