node js 内置 os 函数 find

编程入门 行业动态 更新时间:2024-10-05 03:27:03

node js 内置 os <a href=https://www.elefans.com/category/jswz/34/1771370.html style=函数 find"/>

node js 内置 os 函数 find

我正在使用 shelljs npm 包进行文件遍历:

var shell = require('shelljs');
cFilesOnly = function (file, idx) { return (file.includes('.c')); }
excludeIrrelevantDir = function (file, idx) { return !file.includes('DDD'); }
var files = shell.find('.').filter(cFilesOnly).filter(excludeIrrelevantDir);
console.log(files);

包装很棒:

$ tree
.
├── AAA
│   └── main.c
├── BBB
│   ├── README.md
│   ├── go.c
│   └── run.c
├── DDD
│   └── bad.c
└── main.js

4 directories, 6 files
$ node main.js
[ 'AAA/main.c', 'BBB/go.c', 'BBB/run.c' ]
  • npm 在该包中报告了
    1 high severity vulnerability
    ,所以
  • 我想用 native node os alternative 替换那个包。
  • 我看了(here)但没走多远-我错过了什么?
回答如下:

更多推荐

node js 内置 os 函数 find

本文发布于:2024-05-31 01:17:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   js   node   find   os

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!