-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.js
2 lines (2 loc) · 1.35 KB
/
index.min.js
1
2
#!/usr/bin/env node
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.convert=void 0;const fs=require("fs");const{tw2cn}=require("@dishanqian/cn_and_tw");function convert(e,n){const s={mode:511};try{const t=fs.readFileSync(e).toString();fs.writeFileSync(n,tw2cn(t),s);return true}catch(e){console.error(e);return false}}exports.convert=convert;(()=>{const{argv:e,exit:n}=require("node:process");const s=e.slice(2);let t=false;s.forEach(e=>{switch(e.toLowerCase()){case"/help":case"/h":case"/?":case"-help":case"-h":case"-?":case"--help":case"--h":case"--?":t=true;break;case"--v":case"--version":case"-v":case"-version":case"/v":case"/version":console.log("0.0.1");n();break;default:break}});if(s.length<2||t){console.log("Copyright (c) 2024 [email protected]\n Translate file content from Traditional Chinese to Simplified Chinese.\n\n usage:\n tw2cn sourceFilename goalFilename\n eg:\n tw2cn zh_cn.txt zh_tw.txt\n\n show this tips:\n tw2cn /?|/h|/help|-?|-h|-help|--?|--h|--help\n show version:\n tw2cn /v|/version|-v|-version|--v|--version\n ");n()}const o=new Date;const[c,r]=s;console.log(convert(c,r));const i=new Date;const a=i.getTime()-o.getTime();console.log("Used",a,"milliseconds, it is equivalent to ",parseFloat((a/1e3).toFixed(4)))})();