Skip to content

Commit

Permalink
fix: vitest config coverage dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jul 29, 2023
1 parent 4e30a3f commit 638869b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
push:
branches:
- main
- next
- alpha
- beta

jobs:
release:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
pull_request:
branches:
- main
- next
- alpha
- beta
workflow_dispatch:

jobs:
Expand Down
8 changes: 4 additions & 4 deletions scripts/init/bin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fs = require('fs')
const fs = require('node:fs')
const fsp = fs.promises
const pkgJson = require('../../package.json')
const pkgName = pkgJson.name
// const path = require('path')

async function addBin(json, filename) {
function addBin(json, filename) {
json.bin = {
[pkgName]: filename
}
Expand All @@ -19,7 +19,7 @@ async function addBin(json, filename) {
async function createBin(pkgName) {
try {
await fsp.access('bin')
} catch (error) {
} catch {
await fsp.mkdir('bin')
}
const filename = `bin/${pkgName}.js`
Expand All @@ -30,7 +30,7 @@ async function createBin(pkgName) {
return filename
}

async function createCli() {
function createCli() {
return fsp.writeFile('./src/cli.ts', '// get params from process.argv')
}

Expand Down
27 changes: 16 additions & 11 deletions scripts/init/rename.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs')
const fs = require('node:fs')
const fsp = fs.promises
const path = require('node:path')
const pkg = require('../../package.json')
const path = require('path')

/**
* 临时解决方案
Expand All @@ -13,12 +13,12 @@ function doReplace(ref, name) {
const len = paths.length
switch (len) {
case 1: {
pkg[paths[0]] = pkg[paths[0]].replace(/npm-lib-rollup-template/g, name)
pkg[paths[0]] = pkg[paths[0]].replaceAll('npm-lib-rollup-template', name)
break
}
case 2: {
pkg[paths[0]][paths[1]] = pkg[paths[0]][paths[1]].replace(
/npm-lib-rollup-template/g,
pkg[paths[0]][paths[1]] = pkg[paths[0]][paths[1]].replaceAll(
'npm-lib-rollup-template',
name
)
break
Expand All @@ -27,12 +27,17 @@ function doReplace(ref, name) {
}

function replacePkg(name) {
;['name', 'description', 'bugs.url', 'repository.url', 'homepage'].forEach(
(p) => {
doReplace(p, name)
console.log(`[${p}] replace over`)
}
)
for (const p of [
'name',
'description',
'bugs.url',
'repository.url',
'homepage'
]) {
doReplace(p, name)
console.log(`[${p}] replace over`)
}

return pkg
}

Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineConfig({
globals: true,
coverage: {
enabled: true,
reportsDirectory: 'coverage/vitest'
include: ['src/**']
},
testTimeout: 60_000,
setupFiles: ['./vitest.setup.ts']
Expand Down

0 comments on commit 638869b

Please sign in to comment.