mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refactor templates for create resource tab for ease of testing
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
3e045305ef
commit
0956760626
9 files changed
+237
-103
No files matched your search
@@ -49,6 +49,7 @@ export * from "./toggle-set";
|
||||
export * from "./toJS";
|
||||
export * from "./type-narrowing";
|
||||
export * from "./types";
|
||||
export * from "./wait-for-path";
|
||||
|
||||
import * as iter from "./iter";
|
||||
import * as array from "./array";
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { watch } from "chokidar";
|
||||
import path from "path";
|
||||
|
||||
/**
|
||||
* Wait for `filePath` and all parent directories to exist.
|
||||
* @param filePath The file path to wait until it exists
|
||||
*/
|
||||
export async function waitForPath(filePath: string): Promise<void> {
|
||||
console.log("waiting for", filePath);
|
||||
const dirOfPath = path.dirname(filePath);
|
||||
|
||||
if (dirOfPath === filePath) {
|
||||
// The root of this filesystem, assume it exists
|
||||
console.log("found", filePath);
|
||||
|
||||
return;
|
||||
} else {
|
||||
await waitForPath(dirOfPath);
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
watch(dirOfPath, {
|
||||
depth: 0,
|
||||
}).on("all", (event, path) => {
|
||||
if ((event === "add" || event === "addDir") && path === filePath) {
|
||||
console.log("found", filePath);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user