Enhanced sort
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
/* @flow */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
@@ -6,7 +7,7 @@ process.on("message", obj => {
|
|||||||
// Received a path to process
|
// Received a path to process
|
||||||
fs
|
fs
|
||||||
.readdirSync(obj.path)
|
.readdirSync(obj.path)
|
||||||
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
|
.sort((a, b) => a.localeCompare(b, [], { sensitivity: "base" }))
|
||||||
.filter(file => !file.startsWith("."))
|
.filter(file => !file.startsWith("."))
|
||||||
.forEach(file => process.send(file));
|
.forEach(file => process.send && process.send(file));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ process.stdin.on("data", path => {
|
|||||||
// Received a path to process
|
// Received a path to process
|
||||||
fs
|
fs
|
||||||
.readdirSync(path)
|
.readdirSync(path)
|
||||||
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
|
.sort((a, b) => a.localeCompare(b, [], { sensitivity: "base" }))
|
||||||
.filter(file => !file.startsWith("."))
|
.filter(file => !file.startsWith("."))
|
||||||
.forEach(file => process.stdout.write(file + "\n"));
|
.forEach(file => process.stdout.write(file + "\n"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user