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

Commit 79b72f1

Browse files
committed
fix: process watch files with toUnix
1 parent f123ada commit 79b72f1

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/helpers.ts

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import * as fs from 'fs';
22
import * as path from 'path';
33
import * as host from './host';
44

5+
const double = /\/\//;
6+
export function toUnix(fileName: string): string {
7+
let res: string = fileName.replace(/\\/g, '/');
8+
while (res.match(double)) {
9+
res = res.replace(double, '/');
10+
}
11+
12+
return res;
13+
}
14+
515
function withoutExt(fileName: string): string {
616
return path.join(path.dirname(fileName), path.basename(fileName).split('.')[0]);
717
}

src/index.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ interface Transformation {
2828
map: any;
2929
}
3030

31-
const double = /\/\//;
32-
function toUnix(fileName: string) {
33-
let res: string = fileName.replace(/\\/g, '/');
34-
while (res.match(double)) {
35-
res = res.replace(double, '/');
36-
}
37-
38-
return res;
39-
}
40-
4131
function compiler(webpack: IWebPack, text: string): void {
4232
if (webpack.cacheable) {
4333
webpack.cacheable();
@@ -48,7 +38,7 @@ function compiler(webpack: IWebPack, text: string): void {
4838
let instance = ensureInstance(webpack, options, instanceName);
4939
let state = instance.tsState;
5040
let callback = webpack.async();
51-
let fileName = toUnix(webpack.resourcePath);
41+
let fileName = helpers.toUnix(webpack.resourcePath);
5242

5343
let depsInjector = {
5444
add: (depFileName) => webpack.addDependency(depFileName),

src/instance.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { State } from './host';
22
import * as fs from 'fs';
33
import * as path from 'path';
44
import * as _ from 'lodash';
5-
import { formatError } from './helpers';
5+
import { formatError, toUnix } from './helpers';
66
import { ICompilerInfo } from './host';
77
import { createChecker } from './checker';
88

@@ -319,7 +319,7 @@ function setupWatchRun(compiler, instanceName: string) {
319319
let instance = resolveInstance(watching.compiler, instanceName);
320320
let state = instance.tsState;
321321
let mtimes = watching.compiler.watchFileSystem.watcher.mtimes;
322-
let changedFiles = Object.keys(mtimes);
322+
let changedFiles = Object.keys(mtimes).map(toUnix);
323323

324324
changedFiles.forEach((changedFile) => {
325325
state.fileAnalyzer.validFiles.markFileInvalid(changedFile);

0 commit comments

Comments
 (0)