Skip to content

Commit

Permalink
feat: use runscript v2
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 9, 2024
1 parent 696d846 commit 2d387c3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ cmd/*.js
dist
test/fixtures/example-declarations/typings/
!test/fixtures/example-declarations/node_modules
.package-lock.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"jest-changed-files": "^29.4.2",
"mocha": "^10.2.0",
"mochawesome-with-mocha": "^7.1.3",
"runscript": "^1.5.3",
"runscript": "^2.0.0",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.1.2"
},
Expand Down
6 changes: 3 additions & 3 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const debug = require('node:util').debuglog('egg-bin:postinstall');
const path = require('node:path');
const fs = require('node:fs');
const runscript = require('runscript');
const { runScript } = require('runscript');

// node posintall.js </path/to/egg-ts-helper/dist/bin> <framework-package-name>
// node postintall.js </path/to/egg-ts-helper/dist/bin> <framework-package-name>
const etsBinFile = process.argv[2] || require.resolve('egg-ts-helper/dist/bin');
const frameworkPackageName = process.argv[3] || 'egg';

Expand Down Expand Up @@ -41,6 +41,6 @@ if (npmRunRoot) {
// https://github.com/eggjs/egg-ts-helper/pull/104
process.env.ETS_SCRIPT_FRAMEWORK = frameworkPackageName;
console.log('[egg-bin:postinstall] run %s on %s', etsBinFile, npmRunRoot);
runscript(`node ${etsBinFile}`);
runScript(`node ${etsBinFile}`);
}
}
4 changes: 2 additions & 2 deletions src/middleware/global_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Inject, ApplicationLifecycle, LifecycleHook, LifecycleHookUnit,
Program, CommandContext,
} from '@artus-cli/artus-cli';
import runscript from 'runscript';
import { runScript } from 'runscript';
import { addNodeOptionsToEnv, readPackageJSON, hasTsConfig } from '../utils';

const debug = debuglog('egg-bin:midddleware:global_options');
Expand Down Expand Up @@ -133,7 +133,7 @@ export default class GlobalOptions implements ApplicationLifecycle {
if (ctx.args.declarations) {
const etsBin = require.resolve('egg-ts-helper/dist/bin');
debug('run ets first: %o', etsBin);
await runscript(`node ${etsBin}`);
await runScript(`node ${etsBin}`);
}

if (ctx.args.pkgEgg.revert) {
Expand Down
22 changes: 11 additions & 11 deletions test/ts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert';
import path from 'node:path';
import fs from 'node:fs/promises';
import _cpy from 'cpy';
import runscript from 'runscript';
import { runScript } from 'runscript';
import coffee from './coffee';

const version = Number(process.version.substring(1, 3));
Expand Down Expand Up @@ -228,10 +228,10 @@ describe('test/ts.test.ts', () => {
// install custom ts-node
await fs.rm(path.join(cwd, 'node_modules'), { force: true, recursive: true });
if (process.env.CI) {
// dont use npmmirror.com on CI
await runscript('npx npminstall', { cwd });
// don't use npmmirror.com on CI
await runScript('npx npminstall', { cwd });
} else {
await runscript('npx npminstall -c', { cwd });
await runScript('npx npminstall -c', { cwd });
}

// copy egg to node_modules
Expand Down Expand Up @@ -260,9 +260,9 @@ describe('test/ts.test.ts', () => {
await fs.rm(path.join(cwd, 'node_modules'), { force: true, recursive: true });
if (process.env.CI) {
// dont use npmmirror.com on CI
await runscript('npx npminstall [email protected] --no-save', { cwd });
await runScript('npx npminstall [email protected] --no-save', { cwd });
} else {
await runscript('npx npminstall -c [email protected] --no-save', { cwd });
await runScript('npx npminstall -c [email protected] --no-save', { cwd });
}

// copy egg to node_modules
Expand Down Expand Up @@ -291,10 +291,10 @@ describe('test/ts.test.ts', () => {
// install custom ts-node
await fs.rm(path.join(cwd, 'node_modules'), { force: true, recursive: true });
if (process.env.CI) {
// dont use npmmirror.com on CI
await runscript('npx npminstall [email protected] --no-save', { cwd });
// don't use npmmirror.com on CI
await runScript('npx npminstall [email protected] --no-save', { cwd });
} else {
await runscript('npx npminstall -c [email protected] --no-save', { cwd });
await runScript('npx npminstall -c [email protected] --no-save', { cwd });
}

// copy egg to node_modules
Expand Down Expand Up @@ -389,9 +389,9 @@ describe('test/ts.test.ts', () => {
await fs.rm(path.join(cwd, 'node_modules'), { force: true, recursive: true });
if (process.env.CI) {
// dont use npmmirror.com on CI
await runscript('npx npminstall', { cwd });
await runScript('npx npminstall', { cwd });
} else {
await runscript('npx npminstall -c', { cwd });
await runScript('npx npminstall -c', { cwd });
}

// copy egg to node_modules
Expand Down

0 comments on commit 2d387c3

Please sign in to comment.