diff --git a/.github/workflows/node-4+.yml b/.github/workflows/node-4+.yml new file mode 100644 index 0000000..1accca6 --- /dev/null +++ b/.github/workflows/node-4+.yml @@ -0,0 +1,92 @@ +name: 'Tests: node.js' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-matrix.outputs.requireds }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + versionsAsRoot: true + type: 'majors' + preset: '>=4' + + latest: + needs: [matrix] + name: 'latest majors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.latest) }} + include: + - node-version: '14.' + env: + TZ: America/New_York + - node-version: '13.' + env: + TZ: Europe/London + - node-version: '12.' + env: + TZ: Asia/Seoul + - node-version: '11.' + env: + TZ: America/Los_Angeles + FMTS: misc + - node-version: '10.' + env: + TZ: Europe/Berlin + FMTS: misc + - node-version: '9.' + env: + TZ: Asia/Kolkata + FMTS: misc + - node-version: '8.' + env: + TZ: Asia/Shanghai + FMTS: misc + - node-version: '7.' + env: + TZ: America/Cancun + FMTS: misc + - node-version: '6.' + env: + TZ: Asia/Seoul + FMTS: misc + - node-version: '5.' + env: + TZ: America/Anchorage + FMTS: misc + - node-version: '4.' + env: + TZ: America/Barbados + FMTS: misc + - node-version: '4.4.7' # see GH issue #1150 + env: + TZ: Asia/Tokyo + FMTS: misc + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + - run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64 + - run: sudo chmod a+x /usr/bin/rooster + #- run: make init + #- run: 'cd test_files; make all; cd -' + - run: npm run test + #- run: 'cd packages/ssf; npm install; npm run tests-only; cd -' + + node: + name: 'node 4+' + needs: [latest] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/node-iojs.yml b/.github/workflows/node-iojs.yml new file mode 100644 index 0000000..73b04cc --- /dev/null +++ b/.github/workflows/node-iojs.yml @@ -0,0 +1,45 @@ +name: 'Tests: node.js (io.js)' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-matrix.outputs.requireds }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + type: 'majors' + preset: 'iojs' + + latest: + needs: [matrix] + name: 'latest majors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.matrix.outputs.latest) }} + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + skip-ls-check: true + - run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64 + - run: sudo chmod a+x /usr/bin/rooster + #- run: make init + #- run: 'cd test_files; make all; cd -' + - run: npm run test + #- run: 'cd packages/ssf; npm run tests-only; cd -' + + node: + name: 'io.js' + needs: [latest] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 0000000..ccaff02 --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,32 @@ +name: 'Tests: pretest/posttest' + +on: [pull_request, push] + +jobs: + pretest: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install lts/* && npm install' + with: + node-version: 'lts/*' + - run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64 + - run: sudo chmod a+x /usr/bin/rooster + #- run: make init + #- run: 'cd test_files; make all; cd -' + #- run: npm run pretest + + # posttest: + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@v2 + # - uses: ljharb/actions/node/install@main + # name: 'nvm install lts/* && npm install' + # with: + # node-version: 'lts/*' + # - run: make init + # - run: 'cd test_files; make all; cd -' + # - run: npm run posttest diff --git a/.github/workflows/node-zero.yml b/.github/workflows/node-zero.yml new file mode 100644 index 0000000..5a95268 --- /dev/null +++ b/.github/workflows/node-zero.yml @@ -0,0 +1,88 @@ +name: 'Tests: node.js (0.x)' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + stable: ${{ steps.set-matrix.outputs.requireds }} +# unstable: ${{ steps.set-matrix.outputs.optionals }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + versionsAsRoot: true + preset: '0.x' + + stable: + needs: [matrix] + name: 'stable minors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.stable) }} + include: + - node-version: '0.12.' + env: + TZ: America/Cayman + FMTS: misc + - node-version: '0.10.' + env: + TZ: Pacific/Honolulu + FMTS: misc + #- node-version: '0.8.' + # env: + # TZ: America/Mexico_City + # FMTS: misc + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} + skip-ls-check: true + - run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64 + - run: sudo chmod a+x /usr/bin/rooster + #- run: make init + #- run: 'cd test_files; make all; cd -' + - run: npm run test + #- run: 'cd packages/ssf; npm run tests-only; cd -' + +# unstable: +# needs: [matrix, stable] +# name: 'unstable minors' +# continue-on-error: true +# if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }} +# runs-on: ubuntu-latest + +# strategy: +# fail-fast: false +# matrix: +# node-version: ${{ fromJson(needs.matrix.outputs.unstable) }} +# +# steps: +# - uses: actions/checkout@v2 +# - uses: ljharb/actions/node/install@main +# name: 'nvm install ${{ matrix.node-version }} && npm install' +# with: +# node-version: ${{ matrix.node-version }} +# cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} +# skip-ls-check: true +# - run: sudo curl -Lo /usr/bin/rooster https://github.com/SheetJS/rooster/releases/download/v0.2.0/rooster-v0.2.0-linux-amd64 +# - run: sudo chmod a+x /usr/bin/rooster +# - run: make init +# - run: 'cd test_files; make all; cd -' +# - run: npm run tests-only + + node: + name: 'node 0.x' +# needs: [stable, unstable] + needs: [stable] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/Makefile b/Makefile index 14d5128..47df70a 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ crc32c.flow.js: crc32.flow.js .PHONY: test mocha test mocha: test.js $(TARGET) baseline ## Run test suite - mocha -R spec -t 60000 + ./node_modules/.bin/mocha -R spec -t 60000 .PHONY: ctest ctest: ## Build browser test (into ctest/ subdirectory) @@ -65,7 +65,7 @@ fullint: lint old-lint tslint flow mdlint ## Run all checks .PHONY: lint lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks - @eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json + @eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi .PHONY: old-lint @@ -91,11 +91,11 @@ flow: lint ## Run flow checker cov: misc/coverage.html ## Run coverage test misc/coverage.html: $(TARGET) test.js - mocha --require blanket -R html-cov -t 60000 > $@ + ./node_modules/.bin/mocha --require blanket -R html-cov -t 60000 > $@ .PHONY: coveralls coveralls: ## Coverage Test + Send to coveralls.io - mocha --require blanket --reporter mocha-lcov-reporter -t 60000 | node ./node_modules/coveralls/bin/coveralls.js + ./node_modules/.bin/mocha --require blanket --reporter mocha-lcov-reporter -t 60000 | node ./node_modules/coveralls/bin/coveralls.js MDLINT=README.md .PHONY: mdlint diff --git a/bin/crc32.njs b/bin/crc32.njs index b5b02a1..334e7d2 100755 --- a/bin/crc32.njs +++ b/bin/crc32.njs @@ -33,7 +33,7 @@ function help()/*:number*/ { function version()/*:number*/ { console.log(X.version); return 0; } var fs = require('fs'); -require('exit-on-epipe'); +try { require('exit-on-epipe'); } catch(e) {} function die(msg/*:string*/, ec/*:?number*/)/*:void*/ { console.error(msg); process.exit(ec || 0); } @@ -59,7 +59,14 @@ for(var i = 0; i < args.length; ++i) { case "--hex": case "-x": fmt = "%0.8x"; break; case "--HEX": case "-X": fmt = "%0.8X"; break; case "--format": case "-F": - fmt = ((m!=arg) ? arg.substr(m.length+1) : args[++i])||""; break; + try { + require("printj"); + fmt = ((m!=arg) ? arg.substr(m.length+1) : args[++i])||""; + } catch(e) { + console.error("The `crc-32` module removed the `printj` dependency for formatting"); + console.error("Use the `crc32-cli` module instead:"); + console.error(" $ npx crc32-cli [options] [filename]"); + } break; case "--hex-seed": case "-H": r = 16; /* falls through */ @@ -82,7 +89,15 @@ writable._writev = function(chunks, cb) { cb(); }; writable.on('finish', function() { - console.log(fmt === "" ? crc32 : require("printj").sprintf(fmt, crc32)); + if(fmt === "") console.log(crc32); + else try { console.log(require("printj").sprintf(fmt, crc32)); } catch(e) { + switch(fmt) { + case "%d": console.log(crc32); break; + case "%u": console.log(crc32 >>> 0); break; + case "%0.8x": console.log((crc32 >>> 0).toString(16).padStart(8, "0").toLowerCase()); break; + case "%0.8X": console.log((crc32 >>> 0).toString(16).padStart(8, "0").toUpperCase()); break; + } + } }); if(filename === "-") process.stdin.pipe(writable); diff --git a/bits/01_version.js b/bits/01_version.js index 45bc6f8..d71eb22 100644 --- a/bits/01_version.js +++ b/bits/01_version.js @@ -1 +1 @@ -CRC32.version = '1.2.1'; +CRC32.version = '1.2.2'; diff --git a/crc32.flow.js b/crc32.flow.js index 3a80772..a1f890e 100644 --- a/crc32.flow.js +++ b/crc32.flow.js @@ -25,7 +25,7 @@ var CRC32/*:CRC32Module*/; /*eslint-enable */ /*jshint ignore:end */ }(function(CRC32/*:CRC32Module*/) { -CRC32.version = '1.2.1'; +CRC32.version = '1.2.2'; /*:: type CRC32Type = number; type ABuf = Array | Buffer | Uint8Array; diff --git a/crc32.js b/crc32.js index af85913..c92664a 100644 --- a/crc32.js +++ b/crc32.js @@ -23,7 +23,7 @@ var CRC32; /*eslint-enable */ /*jshint ignore:end */ }(function(CRC32) { -CRC32.version = '1.2.1'; +CRC32.version = '1.2.2'; /*global Int32Array */ function signed_crc_table() { var c = 0, table = new Array(256); diff --git a/crc32c.flow.js b/crc32c.flow.js index ea7872c..5e97c4a 100644 --- a/crc32c.flow.js +++ b/crc32c.flow.js @@ -25,7 +25,7 @@ var CRC32C/*:CRC32Module*/; /*eslint-enable */ /*jshint ignore:end */ }(function(CRC32C/*:CRC32Module*/) { -CRC32C.version = '1.2.1'; +CRC32C.version = '1.2.2'; /*:: type CRC32Type = number; type ABuf = Array | Buffer | Uint8Array; diff --git a/crc32c.js b/crc32c.js index 6247199..447fc8f 100644 --- a/crc32c.js +++ b/crc32c.js @@ -23,7 +23,7 @@ var CRC32C; /*eslint-enable */ /*jshint ignore:end */ }(function(CRC32C) { -CRC32C.version = '1.2.1'; +CRC32C.version = '1.2.2'; /*global Int32Array */ function signed_crc_table() { var c = 0, table = new Array(256); diff --git a/ctest/crc32.js b/ctest/crc32.js index af85913..c92664a 100644 --- a/ctest/crc32.js +++ b/ctest/crc32.js @@ -23,7 +23,7 @@ var CRC32; /*eslint-enable */ /*jshint ignore:end */ }(function(CRC32) { -CRC32.version = '1.2.1'; +CRC32.version = '1.2.2'; /*global Int32Array */ function signed_crc_table() { var c = 0, table = new Array(256); diff --git a/package.json b/package.json index b00267a..a523291 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crc-32", - "version": "1.2.1", + "version": "1.2.2", "author": "sheetjs", "description": "Pure-JS CRC-32", "keywords": [ "crc", "crc32", "checksum" ], @@ -11,10 +11,10 @@ "types": "types/index.d.ts", "typesVersions": { "*": { "*": ["types/index.d.ts" ] } }, "dependencies": { - "printj": "~1.3.1", - "exit-on-epipe": "~1.0.1" }, "devDependencies": { + "printj": "~1.3.1", + "exit-on-epipe": "~1.0.1", "mocha": "~2.5.3", "blanket": "~1.2.3", "codepage": "~1.10.0", diff --git a/packages/crc32-cli/.npmignore b/packages/crc32-cli/.npmignore new file mode 100644 index 0000000..aa1ec1e --- /dev/null +++ b/packages/crc32-cli/.npmignore @@ -0,0 +1 @@ +*.tgz