-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use github action and drop non-lts Node.js support (#4)
BREAKING CHANGE: Drop Node.js < 14 support
- Loading branch information
Showing
11 changed files
with
141 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": [ | ||
"eslint-config-egg" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
Job: | ||
name: Node.js | ||
uses: node-modules/github-actions/.github/workflows/node-test.yml@master | ||
with: | ||
os: 'ubuntu-latest, macos-latest, windows-latest' | ||
version: '14, 16, 18, 20' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
release: | ||
name: Node.js | ||
uses: node-modules/github-actions/.github/workflows/node-release.yml@master | ||
secrets: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | ||
with: | ||
checkTest: false |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,6 @@ | ||
/**! | ||
* sendmessage - index.js | ||
* | ||
* Copyright(c) fengmk2 and other contributors. | ||
* MIT Licensed | ||
* | ||
* Authors: | ||
* fengmk2 <[email protected]> (http://fengmk2.github.com) | ||
*/ | ||
const { isMainThread, parentPort } = require('worker_threads'); | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
var { isMainThread, parentPort } = require('worker_threads'); | ||
|
||
var IS_NODE_DEV_RUNNER = /node\-dev$/.test(process.env._ || ''); | ||
let IS_NODE_DEV_RUNNER = /node\-dev$/.test(process.env._ || ''); | ||
if (!IS_NODE_DEV_RUNNER && process.env.IS_NODE_DEV_RUNNER) { | ||
IS_NODE_DEV_RUNNER = true; | ||
} | ||
|
@@ -38,24 +23,24 @@ module.exports = function send(child, message) { | |
|
||
// child is worker | ||
if (typeof child.postMessage === 'function') { | ||
return child.postMessage(message) | ||
return child.postMessage(message); | ||
} | ||
// in worker thread | ||
if (!isMainThread) { | ||
return parentPort.postMessage(message) | ||
return parentPort.postMessage(message); | ||
} | ||
|
||
// cluster.fork(): child.process is process | ||
// childprocess.fork(): child is process | ||
var connected = child.process ? child.process.connected : child.connected; | ||
const connected = child.process ? child.process.connected : child.connected; | ||
|
||
if (connected) { | ||
return child.send(message); | ||
} | ||
|
||
// just log warnning message | ||
var pid = child.process ? child.process.pid : child.pid; | ||
var err = new Error('channel closed'); | ||
const pid = child.process ? child.process.pid : child.pid; | ||
const err = new Error('channel closed'); | ||
console.warn('[%s][sendmessage] WARN pid#%s channel closed, nothing send\nstack: %s', | ||
Date(), pid, err.stack); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,22 +7,17 @@ | |
"index.js" | ||
], | ||
"scripts": { | ||
"test": "mocha --check-leaks -R spec -t 5000 -r should test/*.test.js", | ||
"test-cov": "node node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- --check-leaks -t 5000 -r should test/*.test.js", | ||
"test-travis": "node node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -- --check-leaks -t 5000 -r should test/*.test.js", | ||
"jshint": "jshint .", | ||
"autod": "autod -w --prefix '~'", | ||
"cnpm": "npm install --registry=https://registry.npm.taobao.org", | ||
"contributors": "contributors -f plain -o AUTHORS" | ||
"test": "mocha --exit -t 5000 test/*.test.js", | ||
"ci": "c8 npm test", | ||
"lint": "eslint ." | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"autod": "*", | ||
"contributors": "*", | ||
"istanbul": "*", | ||
"jshint": "*", | ||
"mm": "^1.5.1", | ||
"mocha": "*", | ||
"c8": "^7.14.0", | ||
"eslint": "^8.42.0", | ||
"eslint-config-egg": "^12.2.1", | ||
"mm": "^3.3.0", | ||
"mocha": "^10.2.0", | ||
"should": "*" | ||
}, | ||
"homepage": "https://github.com/node-modules/sendmessage", | ||
|
@@ -43,8 +38,8 @@ | |
"channel closed" | ||
], | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
"node": ">= 14.17.0" | ||
}, | ||
"author": "fengmk2 <[email protected]> (http://fengmk2.github.com)", | ||
"author": "fengmk2 <[email protected]> (https://github.com/fengmk2)", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,23 @@ | ||
/**! | ||
* sendmessage - test/child.js | ||
* | ||
* Copyright(c) fengmk2 and other contributors. | ||
* MIT Licensed | ||
* | ||
* Authors: | ||
* fengmk2 <[email protected]> (http://fengmk2.github.com) | ||
*/ | ||
const { isMainThread, parentPort } = require('worker_threads'); | ||
const sendmessage = require('..'); | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var { isMainThread, parentPort } = require('worker_threads'); | ||
var sendmessage = require('../'); | ||
|
||
|
||
var listener = function (message) { | ||
const listener = function(message) { | ||
if (message.disconnect) { | ||
process.disconnect(); | ||
} | ||
|
||
sendmessage(process, { | ||
from: 'child', | ||
got: message | ||
got: message, | ||
}); | ||
} | ||
}; | ||
process.on('message', listener); | ||
if (!isMainThread) { | ||
// worker thread | ||
parentPort.on('message', listener) | ||
parentPort.on('message', listener); | ||
} | ||
|
||
sendmessage(process, { | ||
from: 'child', | ||
hi: 'this is a message send to master' | ||
hi: 'this is a message send to master', | ||
}); |
Oops, something went wrong.