Enhanced sort

This commit is contained in:
fkereki
2018-04-12 09:58:00 -03:00
parent 28fb419475
commit 8d8b87ba25
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -1,3 +1,4 @@
/* @flow */
"use strict";
const fs = require("fs");
@@ -6,7 +7,7 @@ process.on("message", obj => {
// Received a path to process
fs
.readdirSync(obj.path)
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.sort((a, b) => a.localeCompare(b, [], { sensitivity: "base" }))
.filter(file => !file.startsWith("."))
.forEach(file => process.send(file));
.forEach(file => process.send && process.send(file));
});
+1 -1
View File
@@ -9,7 +9,7 @@ process.stdin.on("data", path => {
// Received a path to process
fs
.readdirSync(path)
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.sort((a, b) => a.localeCompare(b, [], { sensitivity: "base" }))
.filter(file => !file.startsWith("."))
.forEach(file => process.stdout.write(file + "\n"));