-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathtoLower.js
More file actions
26 lines (21 loc) · 774 Bytes
/
toLower.js
File metadata and controls
26 lines (21 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require('fs');
const path = require('path');
// eslint-disable-next-line no-extend-native
Array.prototype.flatMap = function (lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
function walkSync(dir) {
if (!fs.lstatSync(dir).isDirectory()) {
return dir;
}
return fs.readdirSync(dir).flatMap((f) => walkSync(path.join(dir, f)));
}
['fairy', 'icon', 'pic', 'spine', 'res', 'typeicons', 'text'].flatMap((dir) => walkSync(dir)).forEach((dir) => {
if (/.atlas$/g.test(dir)) {
let atlas = fs.readFileSync(dir).toString();
const textureRegex = /.*.png/g;
atlas = atlas.replace(textureRegex, textureRegex.exec(atlas)[0].toLowerCase());
fs.writeFileSync(dir, atlas);
}
fs.renameSync(dir, dir.toLowerCase());
});