fs.readdirSync和linux LC_COLLATE = C sort之间有差异吗?

时间:2019-04-23 16:36:46

标签: node.js linux sorting fs

当我使用命令

  

查找。型f | LC_COLLATE = C排序

我遇到了

的目录/文件列表
./angular-animate/README.md
./angular-animate/angular-animate.js
./angular-animate/angular-animate.min.js
./angular-animate/angular-animate.min.js.map
./angular-animate/bower.json
./angular-loader/.bower.json
./angular-loader/README.md
./angular-loader/angular-loader.js
./angular-loader/angular-loader.min.js
./angular-loader/angular-loader.min.js.map
./angular-loader/bower.json
./angular-mocks/.bower.json
./angular-mocks/README.md
./angular-mocks/angular-mocks.js
./angular-mocks/bower.json
./angular-resource/.bower.json
./angular-resource/README.md
./angular-resource/angular-resource.js
./angular-resource/angular-resource.min.js
./angular-resource/angular-resource.min.js.map
./angular-resource/bower.json
./angular-route/.bower.json
./angular-route/README.md
./angular-route/angular-route.js
./angular-route/angular-route.min.js
./angular-route/angular-route.min.js.map
./angular-route/bower.json
./angular-touch/.bower.json
./angular-touch/README.md
./angular-touch/angular-touch.js
./angular-touch/angular-touch.min.js
./angular-touch/angular-touch.min.js.map
./angular-touch/bower.json
./angular/.bower.json
./angular/README.md
./angular/angular-csp.css
./angular/angular-mocks.js
./angular/angular-sanitize.js
./angular/angular.js
./angular/angular.min.js
./angular/angular.min.js.gzip
./angular/angular.min.js.map
./angular/bower.json

但是当我运行

function getFileList(dir, filelist) {
    let files = fs.readdirSync(dir);
    let newFileList = filelist || [];
    files.forEach((file) => {
        const dirFile = `${dir}${file}`;
        if (fs.statSync(dirFile).isDirectory()) {
            newFileList = getFileList(`${dirFile}/`, newFileList);
        } else {
            newFileList.push(`${dir}${file}`);
        }
    });
    return newFileList;
}
在同一目录中的

code,。/ angular /目录位于列表的顶部。

./angular/.bower.json
./angular/README.md
./angular/angular-csp.css
./angular/angular-mocks.js
./angular/angular-sanitize.js
./angular/angular.js
./angular/angular.min.js
./angular/angular.min.js.gzip
./angular/angular.min.js.map
./angular/bower.json
./angular-animate/README.md
./angular-animate/angular-animate.js
./angular-animate/angular-animate.min.js
./angular-animate/angular-animate.min.js.map
./angular-animate/bower.json
./angular-loader/.bower.json
./angular-loader/README.md
./angular-loader/angular-loader.js
./angular-loader/angular-loader.min.js
./angular-loader/angular-loader.min.js.map
./angular-loader/bower.json
./angular-mocks/.bower.json
./angular-mocks/README.md
./angular-mocks/angular-mocks.js
./angular-mocks/bower.json
./angular-resource/.bower.json
./angular-resource/README.md
./angular-resource/angular-resource.js
./angular-resource/angular-resource.min.js
./angular-resource/angular-resource.min.js.map
./angular-resource/bower.json
./angular-route/.bower.json
./angular-route/README.md
./angular-route/angular-route.js
./angular-route/angular-route.min.js
./angular-route/angular-route.min.js.map
./angular-route/bower.json
./angular-touch/.bower.json
./angular-touch/README.md
./angular-touch/angular-touch.js
./angular-touch/angular-touch.min.js
./angular-touch/angular-touch.min.js.map
./angular-touch/bower.json

造成这种差异的原因吗?我还试图找出一种算法来纠正事物节点方面的差异,任何人都遇到相同的问题并发现/开发了解决方案?

0 个答案:

没有答案