Enhanced sort
This commit is contained in:
@@ -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));
|
||||
});
|
||||
|
||||
@@ -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"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user