Skip to content

Commit 5782a32

Browse files
authored
Merge pull request #1594 from StoDevX/natsorting
Sort data files in natural sort order when bundling
2 parents 6bdccd1 + d85269c commit 5782a32

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"pify": "3.0.0",
119119
"prettier": "1.4.4",
120120
"react-native-view-shot": "1.12.0",
121-
"react-test-renderer": "16.0.0-alpha.12"
121+
"react-test-renderer": "16.0.0-alpha.12",
122+
"string-natural-compare": "2.0.2"
122123
}
123124
}

scripts/bundle-data-dir.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const yaml = require('js-yaml')
33
const fs = require('fs')
44
const junk = require('junk')
55
const path = require('path')
6+
const natsort = require('string-natural-compare')
67

78
// run cli
89
if (process.mainModule === module) {
@@ -25,6 +26,9 @@ function bundleDataDir({fromDir, toFile}) {
2526
return
2627
}
2728

29+
// sort the files so that 9 comes before 10
30+
files.sort(natsort)
31+
2832
const loaded = files.map(fpath => {
2933
console.log(fpath)
3034
let contents = fs.readFileSync(fpath, 'utf-8')

0 commit comments

Comments
 (0)