Skip to content

Commit

Permalink
fix(compiler-cli): make ngc to work on Windows (#10919)
Browse files Browse the repository at this point in the history
Fixes #10792
  • Loading branch information
marclaval authored and vicb committed Aug 26, 2016
1 parent 4a44832 commit 6c77d71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 6 additions & 5 deletions modules/@angular/compiler-cli/src/reflector_host.ts
Expand Up @@ -16,7 +16,7 @@ import {StaticReflectorHost, StaticSymbol} from './static_reflector';

const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
const DTS = /\.d\.ts$/;
const NODE_MODULES = path.sep + 'node_modules' + path.sep;
const NODE_MODULES = '/node_modules/';
const IS_GENERATED = /\.(ngfactory|css(\.shim)?)$/;

export interface ReflectorHostContext {
Expand All @@ -36,8 +36,8 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
protected program: ts.Program, protected compilerHost: ts.CompilerHost,
protected options: AngularCompilerOptions, context?: ReflectorHostContext) {
// normalize the path so that it never ends with '/'.
this.basePath = path.normalize(path.join(this.options.basePath, '.'));
this.genDir = path.normalize(path.join(this.options.genDir, '.'));
this.basePath = path.normalize(path.join(this.options.basePath, '.')).replace(/\\/g, '/');
this.genDir = path.normalize(path.join(this.options.genDir, '.')).replace(/\\/g, '/');

this.context = context || new NodeReflectorHostContext();
var genPath: string = path.relative(this.basePath, this.genDir);
Expand All @@ -60,7 +60,8 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {

protected resolve(m: string, containingFile: string) {
const resolved =
ts.resolveModuleName(m, containingFile, this.options, this.context).resolvedModule;
ts.resolveModuleName(m, containingFile.replace(/\\/g, '/'), this.options, this.context)
.resolvedModule;
return resolved ? resolved.resolvedFileName : null;
};

Expand Down Expand Up @@ -139,7 +140,7 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
}

private dotRelative(from: string, to: string): string {
var rPath: string = path.relative(from, to);
var rPath: string = path.relative(from, to).replace(/\\/g, '/');
return rPath.startsWith('.') ? rPath : './' + rPath;
}

Expand Down
6 changes: 5 additions & 1 deletion test.sh
Expand Up @@ -10,7 +10,11 @@ if [ $# -eq 0 ]
echo
else
cd `dirname $0`
export NODE_PATH=$NODE_PATH:$(pwd)/dist/all:$(pwd)/dist/tools
if [ -z ${NODE_PATH+x} ]; then
export NODE_PATH=$(pwd)/dist/all:$(pwd)/dist/tools
else
export NODE_PATH=$NODE_PATH:$(pwd)/dist/all/:$(pwd)/dist/tools/
fi
$(npm bin)/tsc -p tools
node dist/tools/tsc-watch/ $1 watch
fi
Expand Down

0 comments on commit 6c77d71

Please sign in to comment.