Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ results

npm-debug.log
node_modules
package-lock.json
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -69,5 +69,13 @@
"hooks": {
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS"
}
},
"nyc": {
"include": [
"lib/**"
],
"branches": 100,
"lines": 100,
"functions": 98
}
}
11 changes: 7 additions & 4 deletions test/RollingFileWriteStream-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -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);
});
});
});
});
14 changes: 7 additions & 7 deletions test/moveAndMaybeCompressFile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand Down