Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit 90728c4

Browse files
committed
Merge pull request #11 from s-panferov/fix/windows-path
fix(*): fix windows path logic, fixes #9
2 parents d30c60c + abbe1d1 commit 90728c4

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

dist/host.js

+11-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/host.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/host.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ export class State {
177177
});
178178
}
179179

180-
var source = this.program.getSourceFile(fileName);
180+
var normalizedFileName = this.normalizePath(fileName);
181+
var source = this.program.getSourceFile(normalizedFileName);
181182
if (!source) {
182183
this.updateProgram();
183-
source = this.program.getSourceFile(fileName);
184+
source = this.program.getSourceFile(normalizedFileName);
184185
if (!source) {
185-
throw new Error(`File ${fileName} was not found in program`);
186+
throw new Error(`File ${normalizedFileName} was not found in program`);
186187
}
187188
}
188189

@@ -213,7 +214,7 @@ export class State {
213214

214215
this.dependencies.clearDependencies(fileName);
215216

216-
var flow = (!!this.files[fileName]) ?
217+
var flow = this.hasFile(fileName) ?
217218
Promise.resolve(false) :
218219
this.readFileAndUpdate(fileName);
219220

@@ -314,6 +315,10 @@ export class State {
314315
}
315316
}
316317

318+
hasFile(fileName: string): boolean {
319+
return this.files.hasOwnProperty(fileName);
320+
}
321+
317322
readFile(fileName: string): Promise<string> {
318323
var readFile = Promise.promisify(this.fs.readFile.bind(this.fs));
319324
return readFile(fileName).then(function (buf) {
@@ -339,6 +344,10 @@ export class State {
339344
return this.updateFile(fileName, text, checked);
340345
}
341346

347+
normalizePath(path: string): string {
348+
return (<any>this.ts).normalizePath(path)
349+
}
350+
342351
resolve(resolver: Resolver, fileName: string, defPath: string): Promise<string> {
343352
var result;
344353

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ function compiler(webpack: WebPack, text: string): void {
9494

9595
var instance = ensureInstance(webpack, options, instanceName);
9696

97+
var state = instance.tsState;
98+
9799
var callback = webpack.async();
98100
var fileName = webpack.resourcePath;
99101
var resolver = <host.Resolver>Promise.promisify(webpack.resolve);
@@ -103,7 +105,6 @@ function compiler(webpack: WebPack, text: string): void {
103105
clear: webpack.clearDependencies.bind(webpack)
104106
};
105107

106-
var state = instance.tsState;
107108

108109
// Here we receive information about what files were changed.
109110
// The way is hacky, maybe we can find something better.

0 commit comments

Comments
 (0)