Make it work on windows

This commit is contained in:
dylan 2023-05-07 13:00:04 -07:00
parent 87d3e6fc9b
commit c53373ea47
3 changed files with 23 additions and 3 deletions

10
cart.ts
View File

@ -1,14 +1,20 @@
import { path } from "./deps.ts";
import initialCart from "./initialCart.json" assert { type: "json" }; import initialCart from "./initialCart.json" assert { type: "json" };
import { Sheet } from "./sheet.ts"; import { Sheet } from "./sheet.ts";
let cart = initialCart as Array<Sheet>; let cart = initialCart as Array<Sheet>;
const virtualPathToRealPath = (virtualFname: string) => {
const realPath = path.join(".", "carts", ...virtualFname.split("/"));
return realPath;
}
export const saveCart = async (fname: string) => { export const saveCart = async (fname: string) => {
await Deno.writeTextFile("./carts/"+fname+".fx", JSON.stringify(getCart())); await Deno.writeTextFile(virtualPathToRealPath(fname+".fx"), JSON.stringify(getCart()));
} }
export const loadCart = async (fname: string) => { export const loadCart = async (fname: string) => {
cart = JSON.parse(await Deno.readTextFile("./carts/"+fname+".fx")); cart = JSON.parse(await Deno.readTextFile(virtualPathToRealPath(fname+".fx")));
} }
export const getCart = () => { export const getCart = () => {

11
deno.lock generated
View File

@ -1,6 +1,17 @@
{ {
"version": "2", "version": "2",
"remote": { "remote": {
"https://deno.land/std@0.186.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462",
"https://deno.land/std@0.186.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3",
"https://deno.land/std@0.186.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0",
"https://deno.land/std@0.186.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b",
"https://deno.land/std@0.186.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0",
"https://deno.land/std@0.186.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000",
"https://deno.land/std@0.186.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1",
"https://deno.land/std@0.186.0/path/mod.ts": "ee161baec5ded6510ee1d1fb6a75a0f5e4b41f3f3301c92c716ecbdf7dae910d",
"https://deno.land/std@0.186.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d",
"https://deno.land/std@0.186.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1",
"https://deno.land/std@0.186.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba",
"https://deno.land/std@0.97.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", "https://deno.land/std@0.97.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58",
"https://deno.land/std@0.97.0/_util/os.ts": "e282950a0eaa96760c0cf11e7463e66babd15ec9157d4c9ed49cc0925686f6a7", "https://deno.land/std@0.97.0/_util/os.ts": "e282950a0eaa96760c0cf11e7463e66babd15ec9157d4c9ed49cc0925686f6a7",
"https://deno.land/std@0.97.0/encoding/base64.ts": "eecae390f1f1d1cae6f6c6d732ede5276bf4b9cd29b1d281678c054dc5cc009e", "https://deno.land/std@0.97.0/encoding/base64.ts": "eecae390f1f1d1cae6f6c6d732ede5276bf4b9cd29b1d281678c054dc5cc009e",

View File

@ -37,4 +37,7 @@ try {
} catch (err) { } catch (err) {
console.log("If you are running this on linux, please make sure you have 'xsel' installed."); console.log("If you are running this on linux, please make sure you have 'xsel' installed.");
throw err; throw err;
} }
// path
export * as path from "https://deno.land/std@0.186.0/path/mod.ts";