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

Commit

Permalink
fix: process watch files with toUnix
Browse files Browse the repository at this point in the history
  • Loading branch information
s-panferov committed Jun 23, 2016
1 parent e1e217b commit 045ffd8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 10 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import * as fs from 'fs';
import * as path from 'path';
import * as host from './host';

const double = /\/\//;
export function toUnix(fileName: string): string {
let res: string = fileName.replace(/\\/g, '/');
while (res.match(double)) {
res = res.replace(double, '/');
}

return res;
}

function withoutExt(fileName: string): string {
return path.join(path.dirname(fileName), path.basename(fileName).split('.')[0]);
}
Expand Down
12 changes: 1 addition & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ interface Transformation {
map: any;
}

const double = /\/\//;
function toUnix(fileName: string) {
let res: string = fileName.replace(/\\/g, '/');
while (res.match(double)) {
res = res.replace(double, '/');
}

return res;
}

function compiler(webpack: IWebPack, text: string): void {
if (webpack.cacheable) {
webpack.cacheable();
Expand All @@ -48,7 +38,7 @@ function compiler(webpack: IWebPack, text: string): void {
let instance = ensureInstance(webpack, options, instanceName);
let state = instance.tsState;
let callback = webpack.async();
let fileName = toUnix(webpack.resourcePath);
let fileName = helpers.toUnix(webpack.resourcePath);

let depsInjector = {
add: (depFileName) => webpack.addDependency(depFileName),
Expand Down
4 changes: 2 additions & 2 deletions src/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { State } from './host';
import * as fs from 'fs';
import * as path from 'path';
import * as _ from 'lodash';
import { formatError } from './helpers';
import { formatError, toUnix } from './helpers';
import { ICompilerInfo } from './host';
import { createChecker } from './checker';

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

changedFiles.forEach((changedFile) => {
state.fileAnalyzer.validFiles.markFileInvalid(changedFile);
Expand Down

0 comments on commit 045ffd8

Please sign in to comment.