Skip to content

Commit

Permalink
Update deps and minimum node 14
Browse files Browse the repository at this point in the history
  • Loading branch information
HughePaul committed Apr 27, 2023
1 parent f729a84 commit d788021
Show file tree
Hide file tree
Showing 4 changed files with 659 additions and 531 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v2
Expand Down
24 changes: 18 additions & 6 deletions lib/backends/fs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* istanbul ignore file */

var glob = require('glob'),
var glob = require('glob').glob,
yaml = require('js-yaml'),
path = require('path'),
fs = require('fs'),
Expand Down Expand Up @@ -46,13 +46,13 @@ module.exports = {

var glb = options.path
.replace('__lng__', '+([a-zA-Z_-])')
.replace('__ns__', '+(+([a-zA-Z_.-]))')
.replace('__ns__', '+(+([a-zA-Z_-])*(.)+([a-zA-Z_-]))')
.replace('__ext__', '@(json|yml|yaml)');
var rgx = options.path
.replace(/\\/g, '\\\\') // Windows hack, noop for unix file paths
.replace(/\./g, '\\.')
.replace('__lng__', '([a-zA-Z_-]+)')
.replace('__ns__', '([a-zA-Z_.-]+)')
.replace('__ns__', '([a-zA-Z_.-]+[a-zA-Z_]+)')
.replace('__ext__', '(json|yml|yaml|__ext__)');
rgx = new RegExp(rgx);

Expand Down Expand Up @@ -84,14 +84,20 @@ module.exports = {
});
}

function sortFiles(a, b) {
if (a.lng !== b.lng) return a.lng < b.lng ? -1 : 1;
if (a.ns !== b.ns) return (a.ns === 'default' || a.ns < b.ns) ? -1 : 1;
if (a.ext !== b.ext) return a.ext < b.ext ? -1 : 1;
return 0;
}

var files = [];

function findFiles(done) {
async.forEachSeries(dirs, function(dir, done) {
var filePath = path.resolve(dir, glb);
glob(filePath, function (err, filenames) {
if (err) return done(err);
glob(filePath).catch(done).then(function (filenames) {
var dirFiles = [];
filenames.forEach(function (filename) {
filename = path.normalize(filename);
var parts = filename.match(rgx).slice(1);
Expand All @@ -102,9 +108,14 @@ module.exports = {

if (lng && ns) {
filename = path.resolve(dir, filename);
files.push({ filename, lng, ns, ext });
dirFiles.push({ filename, dir, lng, ns, ext });
}
});

dirFiles.sort(sortFiles);

files = files.concat(dirFiles);

done();
});
}, done);
Expand All @@ -114,6 +125,7 @@ module.exports = {
var datastore = {};

function readFiles(done) {
console.log('SORTED FILES', files.map(f => f.filename));
datastore = {};
async.forEachSeries(files, function(file, done) {

Expand Down
Loading

0 comments on commit d788021

Please sign in to comment.