refactor: lint scripts and benchmarks

This commit is contained in:
Clark Du 2018-08-10 15:18:54 +01:00
parent efb1d85f89
commit 7c7701d622
4 changed files with 15 additions and 19 deletions

View File

@ -55,7 +55,7 @@
"build:make-start": "node scripts/make-start", "build:make-start": "node scripts/make-start",
"clean": "rimraf dist", "clean": "rimraf dist",
"coverage": "codecov", "coverage": "codecov",
"lint": "eslint --ext .js,.mjs,.vue bin/** lib test examples", "lint": "eslint --ext .js,.mjs,.vue bin/** scripts/** lib test examples benchmarks",
"postinstall": "opencollective postinstall || exit 0", "postinstall": "opencollective postinstall || exit 0",
"prebuild": "yarn clean", "prebuild": "yarn clean",
"security": "nsp check || true", "security": "nsp check || true",

View File

@ -39,8 +39,8 @@ while (match) {
requires = requires.filter(r => excludes.indexOf(r) === -1) requires = requires.filter(r => excludes.indexOf(r) === -1)
// Resolve version constrains // Resolve version constrains
let dependencies = {} const dependencies = {}
requires.forEach(r => { requires.forEach((r) => {
if (!packageJSON.dependencies[r]) { if (!packageJSON.dependencies[r]) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.warn('Cannot resolve dependency version for ' + r) console.warn('Cannot resolve dependency version for ' + r)
@ -50,10 +50,8 @@ requires.forEach(r => {
}) })
// Drop fields // Drop fields
let drops = ['devDependencies', 'scripts', 'nyc', 'types'] const drops = ['devDependencies', 'scripts', 'nyc', 'types']
drops.forEach(k => { drops.forEach(k => delete packageJSON[k])
delete packageJSON[k]
})
// Update dependencies // Update dependencies
packageJSON.dependencies = dependencies packageJSON.dependencies = dependencies
@ -73,12 +71,12 @@ writeFileSync(
// Copy required files // Copy required files
const excludeFiles = ['README.md', '.gitignore'] const excludeFiles = ['README.md', '.gitignore']
packageJSON.files.forEach(file => { packageJSON.files.forEach((file) => {
if (excludeFiles.indexOf(file) !== -1) { if (excludeFiles.indexOf(file) !== -1) {
return return
} }
let src = resolve(rootDir, file) const src = resolve(rootDir, file)
let dst = resolve(startDir, file) const dst = resolve(startDir, file)
// console.log(relative(rootDir, src), '~>', relative(rootDir, dst)) // console.log(relative(rootDir, src), '~>', relative(rootDir, dst))
removeSync(dst) removeSync(dst)
copySync(src, dst) copySync(src, dst)
@ -93,9 +91,7 @@ const extraFiles = [
'dist/nuxt.js', 'dist/nuxt.js',
'dist/nuxt.js.map' 'dist/nuxt.js.map'
] ]
extraFiles.forEach(file => { extraFiles.forEach(file => removeSync(resolve(startDir, file)))
removeSync(resolve(startDir, file))
})
// Patch bin/nuxt-start // Patch bin/nuxt-start
const binStart = resolve(startDir, 'bin/nuxt-start') const binStart = resolve(startDir, 'bin/nuxt-start')