From ccc0dfd23c458b97fd5fbfc900a626af78b8f5bf Mon Sep 17 00:00:00 2001 From: Mounir Date: Tue, 23 Jul 2024 13:56:20 -0400 Subject: [PATCH] chore: v1.1.2 --- bin/sheet2i18n.js | 2 +- index.js | 9 ++++++--- package.json | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/sheet2i18n.js b/bin/sheet2i18n.js index b0a42ab..20b44cc 100644 --- a/bin/sheet2i18n.js +++ b/bin/sheet2i18n.js @@ -11,7 +11,7 @@ const currentDir = process.cwd(); const resolvedConfigPath = path.resolve(currentDir, configPath); try { - sheet2i18n(resolvedConfigPath); + sheet2i18n(resolvedConfigPath, currentDir); } catch (error) { console.error( `Failed to execute sheet2i18n with config path: ${resolvedConfigPath}` diff --git a/index.js b/index.js index 51f3a77..0ddcccd 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,9 @@ const fetch = require("node-fetch"); /** * Load CSV files, parse them, and generate JSON files for localization. * @param {string} configPath - Path to the configuration file. + * @param {string} currentDir - Path to the root folder. */ -async function loadCsv(configPath) { +async function loadCsv(configPath, currentDir) { const { exportPath, tabsUrl, localesKey } = require(configPath); console.log("[+] IMPORTING LOCALES"); @@ -20,8 +21,10 @@ async function loadCsv(configPath) { }) ); + const completeExportPath = path.resolve(currentDir, exportPath); + const rows = responses.flatMap((response) => getParsedCSV(response)); - await handleResponse(localesKey, rows, exportPath); + await handleResponse(localesKey, rows, completeExportPath); } catch (error) { console.error("Error fetching or processing CSV files:", error); } @@ -87,7 +90,7 @@ function writeTranslation(localesKey, rows, locale) { */ async function createJson(exportPath, locale, content) { try { - const filePath = path.resolve(__dirname, `${exportPath}/${locale}.json`); + const filePath = `${exportPath}/${locale}.json`; await fs.writeFile(filePath, content); console.log(`JSON in ${locale} is saved.`); } catch (error) { diff --git a/package.json b/package.json index cb8060f..60b4b16 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { "name": "sheet2i18n", - "version": "1.1.0", + "version": "1.1.2", "description": "Import locale from Google Sheet into Json file.", "main": "index.js", "bin": { - "sheet2i18n": "./bin/sheet2i18n.js" + "sheet2i18n": "bin/sheet2i18n.js" }, "scripts": { "start": "node bin/sheet2i18n.js" }, "repository": { "type": "git", - "url": "https://github.com/AbdousMounir/sheet2i18n.git" + "url": "git+https://github.com/AbdousMounir/sheet2i18n.git" }, "dependencies": { "csv-parse": "^5.5.6"