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 fullpath = fs.realpathSync(`${workdir}/${filename}`);
|
||||
const fullpath = Path.posixPath(`${workdir}/${filename}`);
|
||||
|
||||
if (!fs.existsSync(fullpath) || filename.endsWith(".DS_Store")) {
|
||||
return;
|
||||
@@ -403,7 +403,7 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
|
||||
},
|
||||
|
||||
open: (path, selectedNode) => {
|
||||
path = fs.realpathSync(path);
|
||||
path = Path.posixPath(path);
|
||||
const workspace = get();
|
||||
let editor = workspace.editors.find((v) => v.path === path);
|
||||
if (!editor) {
|
||||
@@ -506,7 +506,7 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
|
||||
if (filename === "node-config.b3-setting") {
|
||||
workspace.loadNodeDefs();
|
||||
} else {
|
||||
const fullpath = fs.realpathSync(`${workspace.workdir}/${filename}`);
|
||||
const fullpath = Path.posixPath(`${workspace.workdir}/${filename}`);
|
||||
const editor = workspace.find(fullpath);
|
||||
if (editor && editor.modifiedTime + 500 < fs.statSync(fullpath).mtimeMs) {
|
||||
if (editor.unsave) {
|
||||
|
||||
+7
-3
@@ -5,12 +5,16 @@ const Path = path;
|
||||
declare module "path" {
|
||||
interface PlatformPath {
|
||||
basenameWithoutExt(path: string): string;
|
||||
posixPath(path: string): string;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||
path.basenameWithoutExt = (path: string) => {
|
||||
return Path.basename(path, Path.extname(path));
|
||||
path.basenameWithoutExt = (str: string) => {
|
||||
return Path.basename(str, Path.extname(str));
|
||||
};
|
||||
|
||||
path.posixPath = (str: string) => {
|
||||
return path.normalize(str).replace(/\\/g, "/");
|
||||
};
|
||||
|
||||
export default Path;
|
||||
Reference in new issue
Block a user