Skip to content

Commit

Permalink
fix(cycle-scripts-es-webpack): Test can now be written ine ES6 as well
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #14, #13
  • Loading branch information
Nick Balestra authored and geovanisouza92 committed Oct 18, 2016
1 parent 2984042 commit 2a45a9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cycle-scripts-es-webpack/scripts/configs/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
3 changes: 3 additions & 0 deletions cycle-scripts-es-webpack/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ module.exports = function (appPath, appName, streamLib, verbose, originalDirecto
'build': 'cycle-scripts build',
'take-off-training-wheels': 'cycle-scripts take-off-training-wheels'
}
appPackage.babel = {
'presets': ['es2015']
}
fs.writeFileSync(
appPackageJson,
JSON.stringify(appPackage, null, 2)
Expand Down
14 changes: 11 additions & 3 deletions cycle-scripts-es-webpack/scripts/take-off-training-wheels.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,28 @@ Object.keys(appPackageJson.devDependencies)
})
devDependencies = Object.assign({}, devDependencies, ownPackageJson.dependencies)

// Delete babel config in package.json
delete appPackageJson.babel

// Write the new package.json
var newPackageJson = Object.assign({}, appPackageJson, {scripts: scripts, devDependencies: devDependencies})
fs.writeFileSync(
appPackageJsonPath,
JSON.stringify(newPackageJson, null, 2)
)

// Copy scripts
mkdirp(scriptsPath, function () {
function copy (script) {
fs.copySync(path.join(__dirname, script), path.join(scriptsPath, script))
function copy (script, subDir, inRoot) {
subDir = subDir || ''
fs.copySync(path.join(__dirname, subDir, script), path.join(inRoot ? '' : scriptsPath, script))
}

// Copy scripts
copy('start.js')
copy('test.js')
copy('build.js')

// Copy configs
copy('.babelrc', 'configs', true)
})

2 changes: 1 addition & 1 deletion cycle-scripts-es-webpack/template/src/app.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var assert = require('assert')
import assert from 'assert'

describe('App', function () {
it('should test something', function () {
Expand Down

0 comments on commit 2a45a9e

Please sign in to comment.