Update workflows

This commit is contained in:
Luis Blanco 2021-04-03 14:05:05 +03:00
parent ae9fd3e8ba
commit 5f52a14c85
7 changed files with 1435 additions and 82 deletions

103
.eslintrc
View File

@ -1,21 +1,32 @@
{
"root": true,
"env": {
"node" : true,
"es6" : true,
"mocha" : true
},
"globals": {
"expect" : true,
"chai" : true,
"sinon" : true
},
"extends": ["eslint:recommended"],
"parserOptions": {
"ecmaVersion": 8,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"parserOptions": {
"ecmaVersion": 2020
},
"overrides": [
{
"files": [
"**/*.test.js"
],
"env": {
"jest": true
},
"plugins": ["jest"],
"rules": {
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error"
}
}
],
"env": {
"node": true,
"es6": true
},
"rules": {
"arrow-parens": ["error", "as-needed"],
@ -49,68 +60,14 @@
"keyword-spacing": ["error", { "before": true, "after": true }],
"space-before-blocks": ["error"],
"space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
"space-infix-ops": ["error"],
"space-unary-ops": [
"error", {
"words": true,
"nonwords": false,
"overrides": {
"!": true
}
}
],
"spaced-comment": [0],
"camelcase": ["error"],
"no-tabs": [0],
"comma-dangle": [0],
"global-require": [0],
"func-names": [0],
"no-param-reassign": [0],
"no-underscore-dangle": [0],
"no-restricted-syntax": [
"error",
{
"selector": "LabeledStatement",
"message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
},
{
"selector": "WithStatement",
"message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
}
],
"no-mixed-operators": [0],
"no-plusplus": [0],
"comma-spacing": [0],
"default-case": [0],
"no-shadow": [0],
"no-console": [0],
"key-spacing": [0],
"no-return-assign": [0],
"consistent-return": [0],
"class-methods-use-this": [0],
"no-multi-spaces": [
"error",
{
"exceptions": {
"VariableDeclarator": true,
"Property": true,
"ImportDeclaration": true
}
}
],
"array-callback-return": [0],
"no-use-before-define": [
"error",
{
"functions": false,
"classes": true,
"variables": true
}
],
"padded-blocks": [0],
"space-in-parens": [0],
"valid-jsdoc": [0],
"no-unused-expressions": [0],
"import/no-dynamic-require": [0]
"node/no-unpublished-require": [0],
"no-process-exit": [0],
"no-console": [0]
}
}

25
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Lint
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14.16.0
- run: npm ci
- run: npm run eslint

View File

@ -10,7 +10,12 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1

View File

@ -90,9 +90,9 @@ export default cpbin;
It is useful for development builds. Use it in your **src/package.json**:
```
"scripts": {
"build": "node-gyp rebuild && node -e \"require('addon-tools-raub/cpbin')('ADDON')\""
},
"scripts": {
"build": "node-gyp rebuild && node -e \"require('addon-tools-raub/cpbin')('ADDON')\""
},
```
Here ADDON should be replaced with the name of your addon, without `.node` extension.
@ -113,7 +113,7 @@ To use it, create a new script for your package, which may as well be named
'use strict';
const install = require('addon-tools-raub/install');
const prefix = 'https://github.com/USER/ADDON-NAME/releases/download';
const tag = process.env.npm_package_config_install;
const tag = 'v1.0.0';
install(`${prefix}/${tag}`);
```
@ -183,7 +183,7 @@ export const rmdir: (name: string) => Promise<void>;
export const rm: (name: string) => Promise<void>;
```
* `read` - (async) Reads a whole file to string, NOT A Buffer.
* `read` - (async) Reads a whole file to string, NOT a Buffer.
* `write` - (async) Write a file.
* `copy` - (async) Copy a file.
* `exists` - (async) Check if a file/folder exists.

1360
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@
"npm": ">=6.14.1"
},
"scripts": {
"eslint": "eslint .",
"test": "cd test && npm run test && cd ..",
"test-ci": "cd test && npm run test-ci && cd ..",
"test-install": "cd test && npm ci && cd ..",
@ -52,5 +53,10 @@
"dependencies": {
"adm-zip": "0.5.4",
"node-addon-api": "3.1.0"
},
"devDependencies": {
"eslint": "^7.23.0",
"eslint-plugin-jest": "^24.3.3",
"eslint-plugin-node": "^11.1.0"
}
}

View File

@ -13,7 +13,7 @@ class WritableBuffer extends Writable {
super();
this._buffer = new Buffer(INITIAL_SIZE);
this._buffer = Buffer.alloc(INITIAL_SIZE);
this._size = 0;
}
@ -24,7 +24,7 @@ class WritableBuffer extends Writable {
return null;
}
const data = new Buffer(this._size);
const data = Buffer.alloc(this._size);
this._buffer.copy(data, 0, 0, this._size);
return data;
@ -41,7 +41,7 @@ class WritableBuffer extends Writable {
const freeSpace = this._buffer.length - this._size;
const factor = Math.ceil((incomingSize - freeSpace) / INCREMENT_SIZE);
const newBuffer = new Buffer(this._buffer.length + (INCREMENT_SIZE * factor));
const newBuffer = Buffer.alloc(this._buffer.length + (INCREMENT_SIZE * factor));
this._buffer.copy(newBuffer, 0, 0, this._size);
this._buffer = newBuffer;