json-excel-cli
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -36,3 +36,3 @@ #!/usr/bin/env node | ||
const jsonArr = excel2json(convertRelativePath(String.raw`${args.r}`)); | ||
const jsonArr = excel2json(process.cwd(), convertRelativePath(process.cwd(), String.raw`${args.r}`)); | ||
writeToFile(process.cwd(), json2FormatLangObj(jsonArr[0]), cmd[0] || "after"); | ||
@@ -43,4 +43,4 @@ spinner.succeed("处理完成\r\n"); // 加载状态 => 成功状态 | ||
let zhJSON = require(convertRelativePath(String.raw`${cmd[0]}`)); | ||
let enJSON = require(convertRelativePath(String.raw`${cmd[1]}`)); | ||
let zhJSON = require(convertRelativePath(__dirname, String.raw`${cmd[0]}`)); | ||
let enJSON = require(convertRelativePath(__dirname, String.raw`${cmd[1]}`)); | ||
json2excel(process.cwd(), zhJSON, enJSON, cmd[2] || "HelloWorld.xlsx"); | ||
@@ -65,6 +65,6 @@ spinner.succeed("处理完成"); // 加载状态 => 成功状态 | ||
// return relative path | ||
function convertRelativePath(pathname) { | ||
// console.log(__dirname, pathname, path.isAbsolute(pathname), path.relative(__dirname, pathname)); | ||
function convertRelativePath(dirname, pathname) { | ||
// console.log(__dirname, pathname, path.isAbsolute(pathname), path.relative(dirname, pathname)); | ||
return path | ||
.relative(__dirname, pathname) | ||
.relative(dirname, pathname) | ||
.split(path.sep) | ||
@@ -71,0 +71,0 @@ .join("/"); |
{ | ||
"name": "json-excel-cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ /* | ||
// 读取多语言对照表的excel文件,并转换为JSON对象 | ||
const excel2json = function(fileName = "hello") { | ||
const excel2json = function(dirname, fileName = "hello.xlsx") { | ||
let jsonArr = []; | ||
@@ -20,3 +20,3 @@ const xlsx = require("xlsx"), | ||
// 获取数据 | ||
const workbook = xlsx.readFile(path.resolve(__dirname, `../${fileName}`)); | ||
const workbook = xlsx.readFile(path.resolve(dirname, fileName)); | ||
var sheet_name_list = workbook.SheetNames; | ||
@@ -103,7 +103,7 @@ // console.time("sheet_to_json"); | ||
// zh语言对象写入文件 | ||
writeFile(path.resolve(dirname, `../${fileName}_zh.json`), JSON.stringify(data.zh, null, 2)).catch(error => { | ||
writeFile(path.resolve(dirname, `${fileName}_zh.json`), JSON.stringify(data.zh, null, 2)).catch(error => { | ||
console.error(error); | ||
}); | ||
// en语言对象写入文件 | ||
writeFile(path.resolve(dirname, `../${fileName}_en.json`), JSON.stringify(data.en, null, 2)).catch(error => { | ||
writeFile(path.resolve(dirname, `${fileName}_en.json`), JSON.stringify(data.en, null, 2)).catch(error => { | ||
console.error(error); | ||
@@ -110,0 +110,0 @@ }); |
@@ -77,3 +77,3 @@ /* | ||
// 写入文件 | ||
writeFile(path.resolve(dirname, `${fileName}`), result).catch(error => { | ||
writeFile(path.resolve(dirname, fileName), result).catch(error => { | ||
console.log(error); | ||
@@ -80,0 +80,0 @@ }); |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
46864
11
890