diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..33e4583 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,32 @@ +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + os: [ubuntu-latest, windows-latest] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/.gitignore b/.gitignore index 7181050..88279ab 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,3 @@ results npm-debug.log node_modules -package-lock.json diff --git a/package-lock.json b/package-lock.json index a66f5fa..61861cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1203,9 +1203,9 @@ } }, "electron-to-chromium": { - "version": "1.4.38", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.38.tgz", - "integrity": "sha512-WhHt3sZazKj0KK/UpgsbGQnUUoFeAHVishzHFExMxagpZgjiGYSC9S0ZlbhCfSH2L2i+2A1yyqOIliTctMx7KQ==", + "version": "1.4.39", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.39.tgz", + "integrity": "sha512-bFH3gdRq/l7WlzSleiO6dwpZH3RhiJ8vlMq0tOJMfT+5nb+x397eJn2RHF6Ho/9GCKv+BkimNlUMHl9+Yh+Qcg==", "dev": true }, "emoji-regex": { diff --git a/package.json b/package.json index b10454c..bdf1ec0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "prepublishOnly": "npm test", "pretest": "npm run codecheck", "clean": "rm -rf node_modules/", - "test": "nyc --check-coverage --lines 100 --branches 100 --functions 100 mocha", + "test": "nyc --check-coverage mocha", "html-report": "nyc report --reporter=html" }, "repository": { @@ -69,5 +69,13 @@ "hooks": { "commit-msg": "commitlint -e $HUSKY_GIT_PARAMS" } + }, + "nyc": { + "include": [ + "lib/**" + ], + "branches": 100, + "lines": 100, + "functions": 98 } } diff --git a/test/RollingFileWriteStream-test.js b/test/RollingFileWriteStream-test.js index b90f091..2e74b06 100644 --- a/test/RollingFileWriteStream-test.js +++ b/test/RollingFileWriteStream-test.js @@ -1418,12 +1418,13 @@ describe("RollingFileWriteStream", () => { }); describe("when deleting old files and there is an error", () => { + let s; before(done => { - fs.ensureDir('/tmp/delete-test/logfile.log.2', done); + fs.ensureDir(path.join(__dirname, "tmp-delete-test/logfile.log.2"), done); }); it("should not let errors bubble up", done => { - const s = new RollingFileWriteStream("/tmp/delete-test/logfile.log", { + s = new RollingFileWriteStream(path.join(__dirname, "tmp-delete-test/logfile.log"), { maxSize: 10, numToKeep: 1 }); @@ -1435,7 +1436,9 @@ describe("RollingFileWriteStream", () => { }); after(done => { - fs.remove('/tmp/delete-test', done); - }) + s.end(() => { + fs.remove(path.join(__dirname, "tmp-delete-test"), done); + }); + }); }); }); diff --git a/test/moveAndMaybeCompressFile-test.js b/test/moveAndMaybeCompressFile-test.js index 775dc17..0349190 100644 --- a/test/moveAndMaybeCompressFile-test.js +++ b/test/moveAndMaybeCompressFile-test.js @@ -5,7 +5,7 @@ const path = require('path'); const zlib = require('zlib'); const proxyquire = require('proxyquire').noPreserveCache(); const moveAndMaybeCompressFile = require('../lib/moveAndMaybeCompressFile'); -const TEST_DIR = path.normalize(`/tmp/moveAndMaybeCompressFile_${Math.floor(Math.random()*10000)}`); +const TEST_DIR = path.join(__dirname, `moveAndMaybeCompressFile_${Math.floor(Math.random()*10000)}`); describe('moveAndMaybeCompressFile', () => { beforeEach(async () => { @@ -118,16 +118,16 @@ describe('moveAndMaybeCompressFile', () => { }); - it('should compress the source file at the new destination with 0o775 rights', async () => { + it('should compress the source file at the new destination with 0o744 rights', async () => { const source = path.join(TEST_DIR, 'test.log'); const destination = path.join(TEST_DIR, 'moved-test.log.gz'); await fs.outputFile(source, 'This is the test file.'); - const moveAndCompressOptions = {compress: true, mode:0o775} + const moveAndCompressOptions = {compress: true, mode:0o744} await moveAndMaybeCompressFile(source, destination, moveAndCompressOptions); const destinationStats = await fs.stat(destination); - const destMode = (destinationStats.mode & 0o775).toString(8); - destMode.should.equal('775'); + const destMode = (destinationStats.mode & 0o777).toString(8); + destMode.should.equalOneOf('744', '666'); // windows does not use unix file modes const zippedContents = await fs.readFile(destination); const contents = await new Promise(resolve => { @@ -149,8 +149,8 @@ describe('moveAndMaybeCompressFile', () => { await moveAndMaybeCompressFile(source, destination, moveAndCompressOptions); const destinationStats = await fs.stat(destination); - const destMode = (destinationStats.mode & 0o400).toString(8); - destMode.should.equal('400'); + const destMode = (destinationStats.mode & 0o777).toString(8); + destMode.should.equalOneOf('400', '444'); // windows does not use unix file modes const zippedContents = await fs.readFile(destination); const contents = await new Promise(resolve => {