jffun-blog

安装依赖

npm i simplebig

Node.js 代码

const fs = require("fs");
const path = require("path");
const S = require("simplebig");

// 要转换的文件夹
const dirPath = "./test";
// 要转换的文件的后缀
const extWhiteList = [".js", ".json", ".wxml", ".wxss"];

traverseDir(dirPath);

function traverseDir(dirPath) {
  fs.readdirSync(dirPath).forEach(function(file) {
    let filepath = path.join(dirPath, file);
    let stat = fs.statSync(filepath);
    if (stat.isDirectory()) {
      traverseDir(filepath);
    } else {
      if (~extWhiteList.indexOf(path.extname(file))) {
        let content = fs.readFileSync(filepath);
        fs.writeFileSync(filepath, S.s2t(content.toString()));
        console.log(filepath);
      }
    }
  });
}

分类:

技术点:

相关文章:

  • 2021-09-27
  • 2021-09-27
  • 2021-08-27
  • 2021-08-27
  • 2021-09-27
  • 2021-09-27
  • 2021-11-20
猜你喜欢
  • 2021-10-09
  • 2021-12-05
  • 2021-08-27
  • 2021-12-09
  • 2021-08-27
  • 2021-12-15
  • 2021-09-17
相关资源
相似解决方案