fix(NA): add normalizePath in order to fix watch optimizer when running on windows. (#26486)

This commit is contained in:
Tiago Costa 2018-12-03 11:35:36 +00:00 committed by GitHub
parent 4ddf9c84ab
commit 95be890860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View file

@ -25,6 +25,7 @@ import { promisify } from 'util';
import del from 'del';
import deleteEmpty from 'delete-empty';
import globby from 'globby';
import normalizePosixPath from 'normalize-path';
const readAsync = promisify(readFile);
const writeAsync = promisify(writeFile);
@ -92,7 +93,15 @@ export class WatchCache {
// delete everything in optimize/.cache directory
// except ts-node
await del(await globby([this.cachePath, `!${this.cachePath}/ts-node/**`], { dot: true }));
await del(
await globby(
[
normalizePosixPath(this.cachePath),
`${normalizePosixPath(`!${this.cachePath}/ts-node/**`)}`,
],
{ dot: true }
)
);
// delete some empty folder that could be left
// from the previous cache path reset action

24
typings/normalize_path/index.d.ts vendored Normal file
View file

@ -0,0 +1,24 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
declare function NormalizePath(path: string, stripTrailing?: boolean): string;
declare module 'normalize-path' {
export = NormalizePath;
}