Skip to content

Commit

Permalink
fix: module installer error after pack (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed May 22, 2022
1 parent 8f10fae commit 6bbf495
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 18 deletions.
168 changes: 161 additions & 7 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"electron:serve": "wait-on tcp:4200 && npm run electron:dev",
"electron:dev:static": "npm run electron:tsc && electron .",
"electron:dev": "npm run electron:tsc && electron . --development",
"build": "npm-run-all -p build:* && npm run electron:tsc && electron-builder build",
"build": "npm-run-all -p build:* && npm run build:static",
"build:static": "npm run electron:tsc && electron-builder build",
"release": "npm-run-all -p build:* && npm run electron:tsc && electron-builder --publish=always",
"test": "npm-run-all --serial test:*",
"electron:tsc": "tsc -p tsconfig.json"
Expand All @@ -37,7 +38,8 @@
"ky": "0.30.0",
"resolve": "^1.22.0",
"rxjs": "7.5.5",
"xml2js": "^0.4.23"
"xml2js": "^0.4.23",
"fix-path": "3.0.0"
},
"devDependencies": {
"@types/cross-spawn": "6.0.2",
Expand Down
1 change: 0 additions & 1 deletion src/app/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function createWindow(): BrowserWindow {
? 'http://localhost:4200'
: `file://${path.join(__dirname, '../../workbench/browser/dist/index.html')}`;
win.loadURL(file);
console.log('processEnv', processEnv);
if (['development'].includes(processEnv)) {
win.webContents.openDevTools({
mode: 'undocked',
Expand Down
9 changes: 4 additions & 5 deletions src/platform/node/extension-manager/lib/handler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
let fixPath=require('fix-path');
import * as path from 'path';
import { ModuleHandlerOptions, ModuleHandlerResult } from '../types';
import { fileExists, writeJson } from '../../../../shared/node/file';
Expand All @@ -7,6 +8,7 @@ import * as spawn from 'cross-spawn';
* 本地模块管理器
* @class ModuleHandler
*/
fixPath();
export class ModuleHandler extends CoreHandler {
/**
* 模块安装源地址
Expand Down Expand Up @@ -80,8 +82,8 @@ export class ModuleHandler extends CoreHandler {
* @param modules
*/
private async execCommand(command: string, modules: string[]): Promise<ModuleHandlerResult> {
return await new Promise((resolve: any): void => {
let args = [command].concat(modules).concat('--color=always').concat('--save');
return await new Promise((resolve: any, reject: any): void => {
let args = [command].concat(modules).concat('--color=always', '--save');
if (!['link', 'unlink', 'uninstall'].includes(command)) {
if (this.registry) {
args = args.concat(`--registry=${this.registry}`);
Expand All @@ -90,16 +92,13 @@ export class ModuleHandler extends CoreHandler {
args = args.concat(`--proxy=${this.proxy}`);
}
}
console.log(args);
const npm = spawn('npm', args, { cwd: this.baseDir });
let output = '';
// @ts-ignore
npm.stdout
.on('data', (data: string) => {
output += data;
})
.pipe(process.stdout);
// @ts-ignore
npm.stderr
.on('data', (data: string) => {
output += data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class ExtensionDetailComponent implements OnInit {
}
manageExtension(operate: string, id) {
this.isOperating = true;
console.log(this.isOperating)
/**
* * WARNING:Sending a synchronous message will block the whole
* renderer process until the reply is received, so use this method only as a last
Expand All @@ -35,7 +36,7 @@ export class ExtensionDetailComponent implements OnInit {
}
}
this.isOperating = false;
}, 0);
}, 100);
}
ngOnInit(): void {}
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"types": ["node"],
"lib": ["es2017", "es2016", "es2015", "dom"],
"baseUrl": "./",
"paths": {
}
"paths": {}
},
"include": ["**/**.ts"],
"exclude": ["node_modules", "**/*.spec.ts", "**/browser/**/*.ts"],
Expand Down

0 comments on commit 6bbf495

Please sign in to comment.