Skip to content

Commit

Permalink
fix: node 6 unhappy again...
Browse files Browse the repository at this point in the history
  • Loading branch information
huafu committed Aug 20, 2018
1 parent 777edf5 commit 703ad0b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
env: {
node: true,
es6: true,
},
extends: 'eslint:recommended',
parserOptions: {
ecmaVersion: 6,
ecmaVersion: 5,
sourceType: 'module',
impliedStrict: true,
},
rules: {
'no-console': ['error', { allow: ['warn', 'error', 'log'] }],
indent: ['error', 2],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
Expand Down
6 changes: 3 additions & 3 deletions preprocessor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
console.warn(
'ts-jest',
'[deprecated]',
`Replace any occurrences of "ts-jest/dist/preprocessor.js" or ` +
` "<rootDir>/node_modules/ts-jest/preprocessor.js"` +
` in the 'transform' section of your Jest config with just "ts-jest".`,
'Replace any occurrences of "ts-jest/dist/preprocessor.js" or ' +
' "<rootDir>/node_modules/ts-jest/preprocessor.js"' +
' in the \'transform\' section of your Jest config with just "ts-jest".'
)

module.exports = require('./dist')
2 changes: 1 addition & 1 deletion scripts/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function setupE2e() {
}

if (!packagesOk) {
if (npm.can.ci) {
if (npm.can.ci()) {
log(` [template: ${name}]`, 'installing packages using "npm ci"')
spawnSync('npm', ['ci'], { cwd: dir })
} else {
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { join } = require('path')
// Except that on npm < 4.0.0 the prepare doesn't exists

module.exports = function createBundle() {
if (!npm.can.prepare) {
if (!npm.can.prepare()) {
logger.log('building ts-jest')
npm.spawnSync(['-s', 'run', 'build'], { cwd: rootDir })
}
Expand Down
46 changes: 19 additions & 27 deletions scripts/lib/npm.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
const { sync: spawnSync } = require('cross-spawn')
const spawn = require('cross-spawn')
const { satisfies } = require('semver')
const memoize = require('lodash.memoize')

const self = {}

Object.defineProperties(self, {
version: {
get: memoize(() =>
self
.spawnSync(['-s', '--version'])
.stdout.toString()
.trim(),
),
},
spawnSync: {
value(args, options = {}) {
return spawnSync('npm', args, options)
},
},
can: {
value: Object.defineProperties(
{},
{
ci: { get: memoize(() => satisfies(self.version, '>=5.7.0')) },
prepare: { get: memoize(() => satisfies(self.version, '>=5.7.0')) },
},
),
},
const version = memoize(() => {
return spawnSync(['-s', '--version'])
.stdout.toString()
.trim()
})

module.exports = self
const spawnSync = (args, options = {}) => {
return spawn.sync('npm', args, options)
}

const can = {
ci: memoize(() => satisfies(version(), '>=5.7.0')),
prepare: memoize(() => satisfies(version(), '>=5.7.0')),
}

module.exports = {
version,
spawnSync,
can,
}

0 comments on commit 703ad0b

Please sign in to comment.