Skip to content

Commit

Permalink
Corrigir build do resources no Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dgadelha committed May 16, 2024
1 parent 5af93fb commit 0b7e509
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/resources/src/atualizar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync, promises as fs } from "node:fs";
import path from "node:path";
import url from "node:url";

import AdmZip from "adm-zip";
import * as rimraf from "rimraf";
Expand All @@ -22,8 +23,8 @@ export async function configurarRecursos() {
await fs.unlink(psZip);
}

const url = "https://github.com/UNIVALI-LITE/Portugol-Studio/archive/master.zip";
const remoteEtag = await getETag(url);
const fileUrl = "https://github.com/UNIVALI-LITE/Portugol-Studio/archive/master.zip";
const remoteEtag = await getETag(fileUrl);
const localEtag = path.join(baseDir, "etag");

console.log("Remote ETag:", remoteEtag);
Expand All @@ -44,7 +45,7 @@ export async function configurarRecursos() {
rimraf.sync(baseDir);
}

await download(url, psZip);
await download(fileUrl, psZip);

console.log("Download concluído, extraindo os recursos de ajuda...");

Expand All @@ -61,8 +62,7 @@ export async function configurarRecursos() {
await fs.unlink(psZip);

console.log("Gerando índice da aba Ajuda...");
await import(path.join(baseDir, "ajuda", "scripts", "topicos.js"));
// require(join(baseDir, "ajuda", "scripts", "topicos"));
await import(url.pathToFileURL(path.join(baseDir, "ajuda", "scripts", "topicos.js")).toString());

console.log("Ajustando arquivos HTML...");
await patchHtmlFiles();
Expand Down
3 changes: 2 additions & 1 deletion packages/resources/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "node:path";
import url from "node:url";

export const baseDir = path.join(path.dirname(new URL(import.meta.url).pathname), "..", "assets");
export const baseDir = path.join(path.dirname(url.fileURLToPath(import.meta.url)), "..", "assets");
export const baseHtmlPath = process.env.BASE_HTML_PATH ?? "";
6 changes: 4 additions & 2 deletions packages/resources/src/helpers/exemplos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const ignoredExamples = [
];

export async function generateExamplesJson(baseDir: string, dir: string) {
console.log(`Obtendo exemplos de ${baseDir}/${dir}`);
const indexDir = path.join(baseDir, dir);

const indexProperties = path.join(baseDir, dir, "index.properties");
console.log(`Obtendo exemplos de ${indexDir}`);

const indexProperties = path.join(indexDir, "index.properties");
const parsedProperties = ini.decode(await fs.readFile(indexProperties, "utf8"));
const keys = Object.keys(parsedProperties);
const items: Array<Record<string, string>> = [];
Expand Down

0 comments on commit 0b7e509

Please sign in to comment.