Skip to content

Commit

Permalink
fix: package.json and npm install in builder
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgao365 committed Aug 24, 2024
1 parent b82a1d2 commit 8e41449
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Configuration } from 'electron-builder';
import type { ResolvedConfig } from 'vite';
import type { PluginOptions } from './types';
import os from 'node:os';
import path from 'node:path';
import { cwd } from 'node:process';
import type { Configuration } from 'electron-builder';
import merge from 'lodash.merge';
import shell from 'shelljs';
import type { ResolvedConfig } from 'vite';
import { createLogger } from './logger';
import type { PluginOptions } from './types';
import { readJson, writeJson } from './utils';

const logger = createLogger();
Expand Down Expand Up @@ -38,8 +38,6 @@ function getMirror() {
}

function getBuilderConfig(options: PluginOptions, resolvedConfig: ResolvedConfig) {
createPkg(options, resolvedConfig);

const config: Configuration = {
directories: {
buildResources: 'electron/build',
Expand Down Expand Up @@ -170,8 +168,10 @@ export async function runElectronBuilder(options: PluginOptions, resolvedConfig:

const DIST_PATH = path.join(cwd(), path.dirname(resolvedConfig.build.outDir));

createPkg(options, resolvedConfig);

logger.info(`create package.json and exec "npm install"`);
shell.exec(`cd ${DIST_PATH} && npm i`);
shell.exec(`cd ${DIST_PATH} && npm install --emit=dev`);

logger.info(`run electron-builder to package app`);
const config = getBuilderConfig(options, resolvedConfig);
Expand Down

0 comments on commit 8e41449

Please sign in to comment.