Skip to content

Commit 3612d05

Browse files
committed
bugfix: pathes were wrong for windows
issue: --cname was broken, 404.html wasnt created error message: Error when trying to deploy: { [Error: ENOENT: no such file or directory, open 'X:\X\\your-angular-project\dist\your-angular-project\CNAME'] resolution: workspace.root was "normalized" (Windows drivers are replaced with `/X/`, where X is the drive letter) but this was breaking with fse.writeFile() and fse.copy(), used asWindowsPath() to fix that again question @mgechev Is there some better / recommend way to solve this? fixes angular-schule#61
1 parent 6981dae commit 3612d05

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Diff for: src/deploy/builder.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
22
import { NodeJsSyncHost } from '@angular-devkit/core/node';
3-
import { experimental, join, normalize, json } from '@angular-devkit/core';
3+
import { experimental, normalize, asWindowsPath } from '@angular-devkit/core';
44
import { Schema } from './schema';
5+
import os from 'os';
6+
import * as path from 'path';
57

68
import deploy from './actions';
79
import * as engine from '../engine/engine';
@@ -38,11 +40,18 @@ export default createBuilder<any>(
3840
throw new Error('Cannot find the project output directory');
3941
}
4042

43+
// console.log('***', workspace.root)
44+
// console.log('***', targets.build.options.outputPath)
45+
// console.log('***', asWindowsPath( workspace.root))
46+
47+
const isWin = os.platform() === 'win32';
48+
const workspaceRoot = !isWin ? workspace.root : asWindowsPath(workspace.root);
49+
4150
try {
4251
await deploy(
4352
engine,
4453
context,
45-
join(workspace.root, targets.build.options.outputPath),
54+
path.join(workspaceRoot, targets.build.options.outputPath),
4655
options
4756
);
4857
} catch (e) {

Diff for: src/engine/engine.ts

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ async function createNotFoundPage(dir: string, options: Schema, logger: logging.
106106
const indexHtml = path.join(dir, 'index.html');
107107
const notFoundPage = path.join(dir, '404.html');
108108

109+
// console.log('***', indexHtml)
110+
// console.log('***', notFoundPage)
111+
109112
try {
110113
return await fse.copy(indexHtml, notFoundPage);
111114
}

0 commit comments

Comments
 (0)