diff --git a/README.md b/README.md index e7b27f127..afc73d38a 100644 --- a/README.md +++ b/README.md @@ -69,12 +69,12 @@ var protobuf = require("protobufjs"); Development: ``` - + ``` Production: ``` - + ``` The `protobuf` namespace will be available globally. diff --git a/cli/targets/json-module.js b/cli/targets/json-module.js index 3fe19158f..00307b808 100644 --- a/cli/targets/json-module.js +++ b/cli/targets/json-module.js @@ -1,14 +1,14 @@ "use strict"; -module.exports = json_modulee; +module.exports = json_module; var path = require("path"), fs = require("fs"); var protobuf = require("../.."); -json_modulee.description = "JSON representation as a module (AMD, CommonJS, global)" +json_module.description = "JSON representation as a module (AMD, CommonJS, global)" -function json_modulee(root, options, callback) { +function json_module(root, options, callback) { if (options.wrap) options.wrap = path.resolve(process.cwd(), options.wrap); else diff --git a/cli/util.js b/cli/util.js index f8619e791..0f638dbac 100644 --- a/cli/util.js +++ b/cli/util.js @@ -4,9 +4,23 @@ var fs = require("fs"), var protobuf = require(".."); +function basenameCompare(a, b) { + var aa = String(a).replace(/\.\w+$/, "").split(/(-?\d*\.?\d+)/g), + bb = String(b).replace(/\.\w+$/, "").split(/(-?\d*\.?\d+)/g); + for (var i = 0, k = Math.min(aa.length, bb.length); i < k; i++) { + var x = parseFloat(aa[i]) || aa[i].toLowerCase(), + y = parseFloat(bb[i]) || bb[i].toLowerCase(); + if (x < y) + return -1; + if (x > y) + return 1; + } + return a.length < b.length ? -1 : 0; +}; + exports.requireAll = function requireAll(dirname) { dirname = path.join(__dirname, dirname); - var files = fs.readdirSync(dirname), + var files = fs.readdirSync(dirname).sort(basenameCompare), all = {}; files.forEach(function(file) { var basename = path.basename(file, ".js"), diff --git a/dist/README.md b/dist/README.md index 049599032..870231c28 100644 --- a/dist/README.md +++ b/dist/README.md @@ -7,12 +7,12 @@ CDN usage Development: ``` - + ``` Production: ``` - + ``` **NOTE:** Remember to replace the version tag with the exact [release](https://github.com/dcodeIO/protobuf.js/releases) your project depends upon. diff --git a/package.json b/package.json index 75e486220..58b25607a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "protobufjs", - "version": "6.0.2", + "version": "6.1.0", "description": "Protocol Buffers for JavaScript.", "author": "Daniel Wirtz", "license": "Apache-2.0",