Merge 3562483587
into 088a1ca4d5
This commit is contained in:
commit
589e7653a9
|
@ -0,0 +1,19 @@
|
|||
import fs from "fs";
|
||||
|
||||
const fileUnlink = (filePath) => {
|
||||
try {
|
||||
if (fs.existsSync(filePath)) {
|
||||
fs.unlinkSync(filePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (e){
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export {
|
||||
fileUnlink as default,
|
||||
fileUnlink
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import mkdirp from 'mkdirp';
|
||||
import _ from 'lodash';
|
||||
|
||||
const mkdirParentsPathSync = (filePath) => {
|
||||
const folderFileIn = ("/" + _.initial(filePath.split("/")).join("/")).replace(/\/\//g, "/");
|
||||
mkdirp.sync(folderFileIn)
|
||||
};
|
||||
|
||||
export {
|
||||
mkdirParentsPathSync as default,
|
||||
mkdirParentsPathSync
|
||||
}
|
|
@ -46,6 +46,14 @@
|
|||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
|
@ -148,6 +156,15 @@
|
|||
"which": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"deasync": {
|
||||
"version": "0.1.24",
|
||||
"resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.24.tgz",
|
||||
"integrity": "sha512-i98vg42xNfRZCymummMAN0rIcQ1gZFinSe3btvPIvy6JFTaeHcumeKybRo2HTv86nasfmT0nEgAn2ggLZhOCVA==",
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"node-addon-api": "^1.7.1"
|
||||
}
|
||||
},
|
||||
"dot": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/dot/-/dot-1.1.3.tgz",
|
||||
|
@ -191,6 +208,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||
},
|
||||
"find-up": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
||||
|
@ -335,6 +357,11 @@
|
|||
"p-locate": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"make-dir": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
|
||||
|
@ -357,6 +384,11 @@
|
|||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
|
||||
},
|
||||
"node-addon-api": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz",
|
||||
"integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg=="
|
||||
},
|
||||
"node-cmd": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-cmd/-/node-cmd-4.0.0.tgz",
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
"node": ">=14"
|
||||
},
|
||||
"dependencies": {
|
||||
"deasync": "^0.1.24",
|
||||
"event-pubsub": "5.0.3",
|
||||
"js-message": "1.0.7",
|
||||
"js-queue": "2.0.2",
|
||||
"lodash": "^4.17.21",
|
||||
"mkdirp": "^1.0.4",
|
||||
"strong-type": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -66,4 +69,4 @@
|
|||
"url": "https://github.com/RIAEvangelist/node-ipc/issues"
|
||||
},
|
||||
"homepage": "http://riaevangelist.github.io/node-ipc/"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ import Defaults from '../entities/Defaults.js';
|
|||
import Client from '../dao/client.js';
|
||||
import Server from '../dao/socketServer.js';
|
||||
import util from 'util';
|
||||
import { mkdirParentsPathSync } from "../helpers/mkdirp.js";
|
||||
import fileUnlink from '../helpers/fileUnlink.js';
|
||||
|
||||
class IPC{
|
||||
constructor(){
|
||||
|
@ -97,7 +99,7 @@ function disconnect(id){
|
|||
delete this.of[id];
|
||||
}
|
||||
|
||||
function serve(path,callback){
|
||||
function serve(path,callback, options={}){
|
||||
if(typeof path=='function'){
|
||||
callback=path;
|
||||
path=false;
|
||||
|
@ -115,6 +117,35 @@ function serve(path,callback){
|
|||
callback=emptyCallback;
|
||||
}
|
||||
|
||||
const {
|
||||
recursive,
|
||||
recreate
|
||||
} = options;
|
||||
|
||||
if (recreate) {
|
||||
try {
|
||||
fileUnlink(path);
|
||||
} catch (e){
|
||||
this.log(
|
||||
'Error deleting socket file',
|
||||
path,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive) {
|
||||
try {
|
||||
mkdirParentsPathSync(path);
|
||||
} catch (e) {
|
||||
this.log(
|
||||
'Error creating socket directory',
|
||||
path,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this.server=new Server(
|
||||
path,
|
||||
this.config,
|
||||
|
|
Loading…
Reference in New Issue