use posix path
This commit is contained in:
1 parent
041b793f20
commit
e6a44d8f39
3 files changed
+11
-7
No files matched your search
+1
-1
Submodule src/behavior3 updated: af8eb167ad...903993458f.
@@ -172,7 +172,7 @@ export type WorkspaceStore = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadFileTree = (workdir: string, filename: string) => {
|
const loadFileTree = (workdir: string, filename: string) => {
|
||||||
const fullpath = fs.realpathSync(`${workdir}/${filename}`);
|
const fullpath = Path.posixPath(`${workdir}/${filename}`);
|
||||||
|
|
||||||
if (!fs.existsSync(fullpath) || filename.endsWith(".DS_Store")) {
|
if (!fs.existsSync(fullpath) || filename.endsWith(".DS_Store")) {
|
||||||
return;
|
return;
|
||||||
@@ -403,7 +403,7 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
open: (path, selectedNode) => {
|
open: (path, selectedNode) => {
|
||||||
path = fs.realpathSync(path);
|
path = Path.posixPath(path);
|
||||||
const workspace = get();
|
const workspace = get();
|
||||||
let editor = workspace.editors.find((v) => v.path === path);
|
let editor = workspace.editors.find((v) => v.path === path);
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
@@ -506,7 +506,7 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
|
|||||||
if (filename === "node-config.b3-setting") {
|
if (filename === "node-config.b3-setting") {
|
||||||
workspace.loadNodeDefs();
|
workspace.loadNodeDefs();
|
||||||
} else {
|
} else {
|
||||||
const fullpath = fs.realpathSync(`${workspace.workdir}/${filename}`);
|
const fullpath = Path.posixPath(`${workspace.workdir}/${filename}`);
|
||||||
const editor = workspace.find(fullpath);
|
const editor = workspace.find(fullpath);
|
||||||
if (editor && editor.modifiedTime + 500 < fs.statSync(fullpath).mtimeMs) {
|
if (editor && editor.modifiedTime + 500 < fs.statSync(fullpath).mtimeMs) {
|
||||||
if (editor.unsave) {
|
if (editor.unsave) {
|
||||||
|
|||||||
+7
-3
@@ -5,12 +5,16 @@ const Path = path;
|
|||||||
declare module "path" {
|
declare module "path" {
|
||||||
interface PlatformPath {
|
interface PlatformPath {
|
||||||
basenameWithoutExt(path: string): string;
|
basenameWithoutExt(path: string): string;
|
||||||
|
posixPath(path: string): string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
path.basenameWithoutExt = (str: string) => {
|
||||||
path.basenameWithoutExt = (path: string) => {
|
return Path.basename(str, Path.extname(str));
|
||||||
return Path.basename(path, Path.extname(path));
|
};
|
||||||
|
|
||||||
|
path.posixPath = (str: string) => {
|
||||||
|
return path.normalize(str).replace(/\\/g, "/");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Path;
|
export default Path;
|
||||||
Reference in new issue
Block a user