@waiting/shared-core
Advanced tools
Comparing version 1.3.3 to 1.5.0
@@ -5,3 +5,3 @@ # Change Log | ||
## [1.3.3](https://github.com/waitingsong/node-shared-core/compare/v1.3.2...v1.3.3) (2019-02-24) | ||
# [1.5.0](https://github.com/waitingsong/node-shared-core/compare/v1.4.1...v1.5.0) (2019-02-26) | ||
@@ -8,0 +8,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.3.3 | ||
* @version 1.5.0 | ||
* @author waiting | ||
@@ -199,2 +199,19 @@ * @license MIT | ||
} | ||
/** | ||
* Validate dll file exists for node-ffi | ||
*/ | ||
async function validateDllFile(path) { | ||
if (!path) { | ||
throw new Error('File path empth ') | ||
} | ||
// only filename. can be loaded by search path such as %system% | ||
if (!path.includes('/')) { | ||
return | ||
} | ||
// absolute path | ||
if (await isPathAccessible(path)) { | ||
return | ||
} | ||
throw new Error('File not exists: ' + path) | ||
} | ||
@@ -208,2 +225,9 @@ /* istanbul ignore next */ | ||
/** Set loading path for node-ffi linking dll */ | ||
function setPathDirectory(path) { | ||
if (path && typeof path === 'string' && process && process.env) { | ||
process.env.PATH = `${process.env.PATH};${path}`; | ||
} | ||
} | ||
/** | ||
@@ -334,3 +358,5 @@ * 搜索指定目录以 file.example 文件为基础生成不带后缀的文件为不带 .example 后缀的文件 | ||
exports.rimraf = rimraf; | ||
exports.validateDllFile = validateDllFile; | ||
exports.setPathDirectory = setPathDirectory; | ||
exports.genFileFromExample = genFileFromExample; | ||
exports.isSkipCommitlint = isSkipCommitlint; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.3.3 | ||
* @version 1.5.0 | ||
* @author waiting | ||
@@ -197,2 +197,19 @@ * @license MIT | ||
} | ||
/** | ||
* Validate dll file exists for node-ffi | ||
*/ | ||
async function validateDllFile(path) { | ||
if (!path) { | ||
throw new Error('File path empth ') | ||
} | ||
// only filename. can be loaded by search path such as %system% | ||
if (!path.includes('/')) { | ||
return | ||
} | ||
// absolute path | ||
if (await isPathAccessible(path)) { | ||
return | ||
} | ||
throw new Error('File not exists: ' + path) | ||
} | ||
@@ -206,2 +223,9 @@ /* istanbul ignore next */ | ||
/** Set loading path for node-ffi linking dll */ | ||
function setPathDirectory(path) { | ||
if (path && typeof path === 'string' && process && process.env) { | ||
process.env.PATH = `${process.env.PATH};${path}`; | ||
} | ||
} | ||
/** | ||
@@ -298,2 +322,2 @@ * 搜索指定目录以 file.example 文件为基础生成不带后缀的文件为不带 .example 后缀的文件 | ||
export { assertNever, assertNeverRx, isWin32, userHome, closeAsync, chmodAsync, copyFileAsync, mkdirAsync, openAsync, readFileAsync, readDirAsync, rmdirAsync, statAsync, unlinkAsync, writeAsync, writeFileAsync, pathAccessible, isPathAccessible, dirExists, isDirExists, fileExists, isFileExists, isDirFileExists, createDir, createDirAsync, createFileAsync, rimraf, genFileFromExample, isSkipCommitlint }; | ||
export { assertNever, assertNeverRx, isWin32, userHome, closeAsync, chmodAsync, copyFileAsync, mkdirAsync, openAsync, readFileAsync, readDirAsync, rmdirAsync, statAsync, unlinkAsync, writeAsync, writeFileAsync, pathAccessible, isPathAccessible, dirExists, isDirExists, fileExists, isFileExists, isDirFileExists, createDir, createDirAsync, createFileAsync, rimraf, validateDllFile, setPathDirectory, genFileFromExample, isSkipCommitlint }; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.3.3 | ||
* @version 1.5.0 | ||
* @author waiting | ||
@@ -12,3 +12,3 @@ * @license MIT | ||
import{throwError as t,defer as e,of as n,from as r,combineLatest as o,forkJoin as i}from"rxjs";import{close as a,chmod as s,copyFile as c,mkdir as p,open as f,readFile as u,readdir as l,rmdir as w,stat as m,unlink as h,write as v,writeFile as d,access as x}from"fs";import{normalize as E,sep as y,resolve as M,dirname as g,join as I}from"path";export{basename,dirname,join,normalize,resolve as pathResolve}from"path";import{map as b,mergeMap as j,scan as D,concatMap as P,last as O,mapTo as T,defaultIfEmpty as R,tap as S,share as N,filter as $,take as B}from"rxjs/operators";import{promisify as C}from"util";export{promisify}from"util";export{tmpdir}from"os";function F(t){throw new Error("Assert Never Unexpected object: "+t)}function G(e){return t(new Error("Assert Never Unexpected object: "+e))}const U=C(a),_=C(s),k=C(c),A=C(p),L=C(f),z=C(u),H=C(l),J=C(w),q=C(m),K=C(h),Q=C(v),V=C(d);function W(t){return e(()=>X(t)).pipe(b(e=>e?E(t):""))}function X(t){return t?new Promise(e=>x(t,t=>e(!t))):Promise.resolve(!1)}function Y(t){if(!t)return n("");const r=E(t);return e(()=>Z(r)).pipe(b(t=>t?r:""))}function Z(t){return t?nt(t,"DIR"):Promise.resolve(!1)}function tt(t){const n=E(t);return e(()=>et(n)).pipe(b(t=>t?n:""))}function et(t){return t?nt(t,"FILE"):Promise.resolve(!1)}function nt(t,e){return t?X(t).then(n=>!!n&&q(t).then(t=>"DIR"===e?t.isDirectory():t.isFile())):Promise.resolve(!1)}function rt(t){if(!t)throw new Error("value of path param invalid");const e=n(E(t)),o=e.pipe(j(t=>r(t.split(y))),D((t,e)=>M(t,e),y)),i=o.pipe(P(ot),O()),a=e.pipe(j(Y),j(t=>t?n(t):i));return a}function ot(t,r){return W(t).pipe(j(r=>r?n(r):e(()=>A(t,493)).pipe(T(t))))}async function it(t){if(t){const e=E(t);return await Z(e)||await e.split(y).reduce(async(t,e)=>{const n=M(await t,e);return await X(n)||await A(n,493),n},Promise.resolve(y)),e}throw new Error("value of path param invalid")}async function at(t,e,n){const r=g(t);if(!r)throw new Error("folder empty");await Z(r)||await it(r);const o=E(t);if(!await et(o)){const t=n||{mode:416};Buffer.isBuffer(e)?await V(o,e,t):"object"==typeof e?await V(o,JSON.stringify(e)):await V(o,e,t)}return o}async function st(t){t&&(await ct(t),await Z(t)&&await J(t))}async function ct(t){if(t&&await X(t)){if(await et(t))return void await K(t);const e=await H(t);if(e.length)for(const n of e)await ct(I(t,n));else await J(t)}}const pt="win32"===process.platform,ft=E(pt?process.env.USERPROFILE||"":`${process.env.HOME}`);async function ut(t,e){const n=[];for(const r of e){const e=I(t,r.replace(/\.{2,}/,"/"));if(!await X(e))continue;const o=await H(e);for(const t of o){if(!lt(t))continue;const o=I(e,t),i=wt(t),a=I(e,i);await X(a)||(await k(o,a),n.push(`${r}/${i}`))}}return n}function lt(t){if(!t)return!1;if(".example"===t)return!1;const e=t.split(".");return e.length>1&&"example"===e[e.length-1]}function wt(t){const e=t.split(".");return e.length>1&&"example"===e[e.length-1]?e.slice(0,e.length-1).join("."):t}function mt(t){const{baseDir:e,COMMIT_EDITMSG:a,branchName:s,protectBranch:c,skipMsg:p}=t,f=I(e,a);if(!a)return console.info("COMMIT_EDITMSG value blank"),n(1);const u=r(c).pipe(R()),l=r(p).pipe(R()),w=W(f).pipe(S(t=>{t||(console.info(`COMMIT_EDITMSG file not exists: "${f}"`),process.exit(1))}),j(t=>z(t,{encoding:"utf8"})),b(t=>{const e=t.split(/\n|\r\n/)[0];return{head:e,msg:t}}),N()),m=o(n(s),u).pipe(b(([t,e])=>!(!e||!e.test(t))),$(t=>t),T(0),R(1)),h=o(w,l).pipe(b(([{head:t},e])=>!(!e||!e.test(t))),$(t=>t),T(1),R(0)),v=i(m,h).pipe(b(([t,e])=>t&e),R(0),B(1));return v}export{F as assertNever,G as assertNeverRx,pt as isWin32,ft as userHome,U as closeAsync,_ as chmodAsync,k as copyFileAsync,A as mkdirAsync,L as openAsync,z as readFileAsync,H as readDirAsync,J as rmdirAsync,q as statAsync,K as unlinkAsync,Q as writeAsync,V as writeFileAsync,W as pathAccessible,X as isPathAccessible,Y as dirExists,Z as isDirExists,tt as fileExists,et as isFileExists,nt as isDirFileExists,rt as createDir,it as createDirAsync,at as createFileAsync,st as rimraf,ut as genFileFromExample,mt as isSkipCommitlint}; | ||
import{throwError as t,defer as e,of as n,from as r,combineLatest as o,forkJoin as i}from"rxjs";import{close as s,chmod as a,copyFile as c,mkdir as p,open as f,readFile as u,readdir as l,rmdir as w,stat as m,unlink as h,write as v,writeFile as d,access as x}from"fs";import{normalize as E,sep as y,resolve as g,dirname as M,join as I}from"path";export{basename,dirname,join,normalize,resolve as pathResolve}from"path";import{map as P,mergeMap as T,scan as b,concatMap as j,last as D,mapTo as O,defaultIfEmpty as $,tap as F,share as R,filter as S,take as A}from"rxjs/operators";import{promisify as N}from"util";export{promisify}from"util";export{tmpdir}from"os";function B(t){throw new Error("Assert Never Unexpected object: "+t)}function C(e){return t(new Error("Assert Never Unexpected object: "+e))}const G=N(s),H=N(a),U=N(c),_=N(p),k=N(f),L=N(u),z=N(l),J=N(w),q=N(m),K=N(h),Q=N(v),V=N(d);function W(t){return e(()=>X(t)).pipe(P(e=>e?E(t):""))}function X(t){return t?new Promise(e=>x(t,t=>e(!t))):Promise.resolve(!1)}function Y(t){if(!t)return n("");const r=E(t);return e(()=>Z(r)).pipe(P(t=>t?r:""))}function Z(t){return t?nt(t,"DIR"):Promise.resolve(!1)}function tt(t){const n=E(t);return e(()=>et(n)).pipe(P(t=>t?n:""))}function et(t){return t?nt(t,"FILE"):Promise.resolve(!1)}function nt(t,e){return t?X(t).then(n=>!!n&&q(t).then(t=>"DIR"===e?t.isDirectory():t.isFile())):Promise.resolve(!1)}function rt(t){if(!t)throw new Error("value of path param invalid");const e=n(E(t)),o=e.pipe(T(t=>r(t.split(y))),b((t,e)=>g(t,e),y)),i=o.pipe(j(ot),D()),s=e.pipe(T(Y),T(t=>t?n(t):i));return s}function ot(t,r){return W(t).pipe(T(r=>r?n(r):e(()=>_(t,493)).pipe(O(t))))}async function it(t){if(t){const e=E(t);return await Z(e)||await e.split(y).reduce(async(t,e)=>{const n=g(await t,e);return await X(n)||await _(n,493),n},Promise.resolve(y)),e}throw new Error("value of path param invalid")}async function st(t,e,n){const r=M(t);if(!r)throw new Error("folder empty");await Z(r)||await it(r);const o=E(t);if(!await et(o)){const t=n||{mode:416};Buffer.isBuffer(e)?await V(o,e,t):"object"==typeof e?await V(o,JSON.stringify(e)):await V(o,e,t)}return o}async function at(t){t&&(await ct(t),await Z(t)&&await J(t))}async function ct(t){if(t&&await X(t)){if(await et(t))return void await K(t);const e=await z(t);if(e.length)for(const n of e)await ct(I(t,n));else await J(t)}}async function pt(t){if(!t)throw new Error("File path empth ");if(t.includes("/")&&!await X(t))throw new Error("File not exists: "+t)}const ft="win32"===process.platform,ut=E(ft?process.env.USERPROFILE||"":`${process.env.HOME}`);function lt(t){t&&"string"==typeof t&&process&&process.env&&(process.env.PATH=`${process.env.PATH};${t}`)}async function wt(t,e){const n=[];for(const r of e){const e=I(t,r.replace(/\.{2,}/,"/"));if(!await X(e))continue;const o=await z(e);for(const t of o){if(!mt(t))continue;const o=I(e,t),i=ht(t),s=I(e,i);await X(s)||(await U(o,s),n.push(`${r}/${i}`))}}return n}function mt(t){if(!t)return!1;if(".example"===t)return!1;const e=t.split(".");return e.length>1&&"example"===e[e.length-1]}function ht(t){const e=t.split(".");return e.length>1&&"example"===e[e.length-1]?e.slice(0,e.length-1).join("."):t}function vt(t){const{baseDir:e,COMMIT_EDITMSG:s,branchName:a,protectBranch:c,skipMsg:p}=t,f=I(e,s);if(!s)return console.info("COMMIT_EDITMSG value blank"),n(1);const u=r(c).pipe($()),l=r(p).pipe($()),w=W(f).pipe(F(t=>{t||(console.info(`COMMIT_EDITMSG file not exists: "${f}"`),process.exit(1))}),T(t=>L(t,{encoding:"utf8"})),P(t=>{const e=t.split(/\n|\r\n/)[0];return{head:e,msg:t}}),R()),m=o(n(a),u).pipe(P(([t,e])=>!(!e||!e.test(t))),S(t=>t),O(0),$(1)),h=o(w,l).pipe(P(([{head:t},e])=>!(!e||!e.test(t))),S(t=>t),O(1),$(0)),v=i(m,h).pipe(P(([t,e])=>t&e),$(0),A(1));return v}export{B as assertNever,C as assertNeverRx,ft as isWin32,ut as userHome,G as closeAsync,H as chmodAsync,U as copyFileAsync,_ as mkdirAsync,k as openAsync,L as readFileAsync,z as readDirAsync,J as rmdirAsync,q as statAsync,K as unlinkAsync,Q as writeAsync,V as writeFileAsync,W as pathAccessible,X as isPathAccessible,Y as dirExists,Z as isDirExists,tt as fileExists,et as isFileExists,nt as isDirFileExists,rt as createDir,it as createDirAsync,st as createFileAsync,at as rimraf,pt as validateDllFile,lt as setPathDirectory,wt as genFileFromExample,vt as isSkipCommitlint}; | ||
//# sourceMappingURL=index.esm.min.js.map |
export * from './asset'; | ||
export * from './consts'; | ||
export * from './utils'; | ||
export * from './helper'; | ||
export * from './init-example-file'; | ||
export * from './test-skip-commitlint'; |
export * from './asset' | ||
export * from './consts' | ||
export * from './utils' | ||
export * from './helper' | ||
export * from './init-example-file' | ||
export * from './test-skip-commitlint' |
@@ -66,1 +66,5 @@ /// <reference types="node" /> | ||
export declare function rimraf(path: string): Promise<void>; | ||
/** | ||
* Validate dll file exists for node-ffi | ||
*/ | ||
export declare function validateDllFile(path: string): Promise<void>; |
@@ -177,1 +177,18 @@ import { access, chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, stat, unlink, write, writeFile, } from 'fs' | ||
} | ||
/** | ||
* Validate dll file exists for node-ffi | ||
*/ | ||
export async function validateDllFile(path) { | ||
if (!path) { | ||
throw new Error('File path empth ') | ||
} | ||
// only filename. can be loaded by search path such as %system% | ||
if (!path.includes('/')) { | ||
return | ||
} | ||
// absolute path | ||
if (await isPathAccessible(path)) { | ||
return | ||
} | ||
throw new Error('File not exists: ' + path) | ||
} |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "1.3.3", | ||
"version": "1.5.0", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63285
23
1047
21