Skip to content

Commit

Permalink
@dr-js/dev@0.4.0-dev.7
Browse files Browse the repository at this point in the history
notable change:
- add: `webpack-json-pick-loader` to filter `package.json` explicitly, related: webpack/webpack#11676
- fix: ci: enable color on GitHub Actions
- fix: `npxLazy` re-run and test
- script sort
- package update
  • Loading branch information
dr-js committed Oct 27, 2020
1 parent bce698a commit fc9de71
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 74 deletions.
2 changes: 1 addition & 1 deletion SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
| babel-plugin-minify-replace | ^0.5.0 |
| babel-plugin-module-resolver | ^4.0.0 |
| babel-plugin-styled-components | ^1.11.1 |
| eslint | ^7.12.0 |
| eslint | ^7.12.1 |
| eslint-plugin-import | ^2.22.1 |
| eslint-plugin-node | ^11.1.0 |
| eslint-plugin-promise | ^4.2.1 |
Expand Down
131 changes: 74 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@dr-js/dev",
"version": "0.4.0-dev.6",
"version": "0.4.0-dev.7",
"description": "A collection of strange functions, for development",
"author": "dr-js",
"license": "MIT",
Expand Down Expand Up @@ -33,7 +33,7 @@
"// test ========================": "",
"test-T": "node ./output-gitignore/bin --TFS .test.js -T",
"test-T-dev": "dr-dev --EE BABEL_ENV=dev -E -- node ./output-gitignore/bin --TR @babel/register --TFS .test.js -T",
"test-dev": "npm run test-T-dev -- source/output.test.js",
"test-dev": "npm run test-T-dev -- source/node/npm/npxLazy.test.js",
"test-source": "npm run test-T-dev -- source/",
"test-output-library": "npm run test-T -- output-gitignore/library/",
"test-output-module": "npm run test-T-dev -- output-gitignore/module/",
Expand All @@ -50,12 +50,12 @@
"npm": ">=6.14"
},
"dependencies": {
"@dr-js/core": "0.4.0-dev.7",
"@dr-js/node": "0.4.0-dev.3"
"@dr-js/core": "0.4.0-dev.8",
"@dr-js/node": "0.4.0-dev.5"
},
"devDependencies": {
"@dr-js/dev": "0.4.0-dev.5",
"@dr-js/dev-web": "0.4.0-dev.5"
"@dr-js/dev": "0.4.0-dev.6",
"@dr-js/dev-web": "0.4.0-dev.6"
},
"sideEffects": false
}
2 changes: 1 addition & 1 deletion resource/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"eslint-config-almost-standard-v14.js"
],
"dependencies": {
"eslint": "^7.12.0",
"eslint": "^7.12.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1"
Expand Down
9 changes: 6 additions & 3 deletions source/node/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { clock } from '@dr-js/core/module/common/time'
import { time } from '@dr-js/core/module/common/format'
import { clamp } from '@dr-js/core/module/common/math/base'

import { configureTerminalColor } from '@dr-js/node/module/module/TerminalColor'

import { loadEnvKey, saveEnvKey, __VERBOSE__ } from './env'

const EMPTY_FUNC = () => {}

const TerminalColor = configureTerminalColor()
const getLogger = (
title = 'dev',
quiet = false,
Expand Down Expand Up @@ -33,10 +36,10 @@ const getLogger = (
const padLog = (...args) => {
const start = `## ${args.join(' ')} `
const end = ` [${title}|${getPadTime()}]`
logFunc(`\n${start.padEnd(padWidth - end.length, '-')}${end}`)
logFunc(`\n${start.padEnd(padWidth - end.length, '-')}${TerminalColor.fg.yellow(end)}`)
}
const stepLog = (...args) => logFunc(`- (+${getStepTime()}) ${args.join(' ')}`)
const log = (...args) => logFunc(`- ${args.join(' ')}`)
const stepLog = (...args) => logFunc(`- ${TerminalColor.fg.yellow(`(+${getStepTime()})`)} ${args.join(' ')}`)
const log = (...args) => logFunc(TerminalColor.fg.darkGray(`- ${args.join(' ')}`))
const devLog = __VERBOSE__ ? log : EMPTY_FUNC

return quiet
Expand Down
4 changes: 4 additions & 0 deletions source/node/npm/npxLazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ const runNpx = async ( // TODO: consider move to `npm exec` since the `npx|libnp
args = [],
tabLog
) => {
// NOTE: with this method, there's no way to know when the process ends and the end result,
// so outer code should just bail out, and let the process itself run to end
const pathNpxCli = fromNpmNodeModules('../bin/npx-cli.js') // exist in both `npm@6` and `npm@7`
tabLog(1, 'args:', ...args)
tabLog(1, 'pathNpxCli:', pathNpxCli)

// rewrite `process.argv` to fake npx command so `npx-cli.js` can do it's job
process.argv.length = 1 // keep node binary
process.argv.push(pathNpxCli, ...args)

delete require.cache[ require.resolve(pathNpxCli) ] // reset cache or the code in require will only run once
return require(pathNpxCli)
}

Expand Down
9 changes: 5 additions & 4 deletions source/node/npm/npxLazy.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { doNotThrowAsync } from '@dr-js/core/module/common/verify'
import { setTimeoutAsync } from '@dr-js/core/module/common/time'

import {
runNpx
Expand All @@ -11,12 +12,12 @@ const tabLog = (level, ...args) => info(`${' '.repeat(level)}${args.join(' ')}`
describe('Node.Npm.npxLazy', () => {
it('runNpx()', async () => {
await doNotThrowAsync(async () => {
const result = await runNpx([ 'node', '-v' ], tabLog) // { code: 0, stdout: '', stderr: '' }
info(JSON.stringify(result))
await runNpx([ 'node', '-v' ], tabLog)
await setTimeoutAsync(256) // wait run to end
})
await doNotThrowAsync(async () => {
const result = await runNpx([ 'npm', '-v' ], tabLog) // { code: 0, stdout: '', stderr: '' }
info(JSON.stringify(result))
await runNpx([ 'npm', '-v' ], tabLog)
await setTimeoutAsync(256) // wait run to end
})
})
})

0 comments on commit fc9de71

Please sign in to comment.