Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should support windows and Node.js 14 #223

Merged
merged 16 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
name: Node.js
uses: artusjs/github-actions/.github/workflows/node-test.yml@v1
with:
os: 'ubuntu-latest, macos-latest'
version: '16, 18'
os: 'ubuntu-latest, macos-latest, windows-latest'
version: '14, 16, 18'
7 changes: 6 additions & 1 deletion scripts/start-cluster.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const debug = require('util').debuglog('egg-bin:lib:start-cluster');

debug('argv: %o', process.argv);
const options = JSON.parse(process.argv[2]);
let optionsJSONString = process.argv[2];
if (process.platform === 'win32' && optionsJSONString.startsWith('\'')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

太特殊了,我还是改成 fork 来执行。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

拿到后变成啥样子了? 我印象中很多年前也是写 egg-scripts 时,被 win 的字符串转译搞疯了

// '{"baseDir":" => {"baseDir":
optionsJSONString = optionsJSONString.startsWith(1, optionsJSONString.length - 1);
}
const options = JSON.parse(optionsJSONString);
debug('start cluster options: %o', options);
require(options.framework).startCluster(options);
8 changes: 4 additions & 4 deletions test/cmd/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import net from 'node:net';
import detect from 'detect-port';
import coffee from '../coffee';

describe('test/cmd/dev.test.ts', () => {
describe.only('test/cmd/dev.test.ts', () => {
const eggBin = path.join(__dirname, '../../src/bin/cli.ts');
const fixtures = path.join(__dirname, '../fixtures');
const cwd = path.join(fixtures, 'demo-app');

it('should startCluster success', () => {
return coffee.fork(eggBin, [ 'dev' ], { cwd })
// .debug()
return coffee.fork(eggBin, [ 'dev' ], { cwd, env: { NODE_DEBUG: 'egg-bin*' } })
.debug()
.expect('stdout', /"workers":1/)
.expect('stdout', /"baseDir":".*?demo-app"/)
.expect('stdout', /"framework":".*?aliyun-egg"/)
Expand All @@ -21,7 +21,7 @@ describe('test/cmd/dev.test.ts', () => {

it('should dev start with custom NODE_ENV', () => {
return coffee.fork(eggBin, [ 'dev' ], { cwd, env: { NODE_ENV: 'prod' } })
// .debug()
.debug()
.expect('stdout', /"workers":1/)
.expect('stdout', /"baseDir":".*?demo-app"/)
.expect('stdout', /"framework":".*?aliyun-egg"/)
Expand Down