Skip to content

Commit

Permalink
fix(web): ensure file server works on windows (#9449)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored and FrozenPandaz committed Mar 25, 2022
1 parent 1e978f4 commit df5db9d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/web/src/executors/file-server/file-server.impl.ts
Expand Up @@ -5,6 +5,10 @@ import { readFileSync } from 'fs';
import { Schema } from './schema';
import { watch } from 'chokidar';
import { workspaceLayout } from '@nrwl/workspace/src/core/file-utils';
import { platform } from 'os';

// platform specific command name
const pmCmd = platform() === 'win32' ? `npx.cmd` : 'npx';

function getHttpServerArgs(options: Schema) {
const args = ['-c-1'];
Expand Down Expand Up @@ -36,7 +40,7 @@ function getHttpServerArgs(options: Schema) {
}

function getBuildTargetCommand(options: Schema) {
const cmd = ['npx', 'nx', 'run', options.buildTarget];
const cmd = ['nx', 'run', options.buildTarget];
if (options.withDeps) {
cmd.push(`--with-deps`);
}
Expand Down Expand Up @@ -115,8 +119,8 @@ export default async function* fileServerExecutor(
if (!running) {
running = true;
try {
const [cmd, ...args] = getBuildTargetCommand(options);
execFileSync(cmd, args, {
const args = getBuildTargetCommand(options);
execFileSync(pmCmd, args, {
stdio: [0, 1, 2],
});
} catch {}
Expand All @@ -132,7 +136,7 @@ export default async function* fileServerExecutor(
const outputPath = getBuildTargetOutputPath(options, context);
const args = getHttpServerArgs(options);

const serve = execFile('npx', ['http-server', outputPath, ...args], {
const serve = execFile(pmCmd, ['http-server', outputPath, ...args], {
cwd: context.root,
env: {
FORCE_COLOR: 'true',
Expand Down

0 comments on commit df5db9d

Please sign in to comment.