@waiting/shared-core
Advanced tools
Comparing version 2.2.0 to 3.0.0
@@ -5,2 +5,4 @@ # Changelog | ||
## [3.0.0](https://github.com/waitingsong/node-shared-core/compare/v2.2.0...v3.0.0) (2019-08-28) | ||
## [2.2.0](https://github.com/waitingsong/node-shared-core/compare/v2.1.0...v2.2.0) (2019-08-28) | ||
@@ -7,0 +9,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 2.2.0 | ||
* @version 3.0.0 | ||
* @author waiting | ||
@@ -299,82 +299,2 @@ * @license MIT | ||
/* eslint-disable no-await-in-loop */ | ||
// const rootDir = join(__dirname, '..') | ||
async function genFileFromExample(rootDir, list) { | ||
const copied = []; | ||
for (const dir of list) { | ||
const path$1 = path.join(rootDir, dir.replace(/\.{2,}/u, '/')); | ||
if (!await isPathAccessible(path$1)) { | ||
continue; | ||
} | ||
const files = await readDirAsync(path$1); | ||
for (const file of files) { | ||
if (!hasExampleSuffix(file)) { | ||
continue; | ||
} | ||
const source = path.join(path$1, file); | ||
const stripped = stripExampleSuffix(file); | ||
const target = path.join(path$1, stripped); | ||
if (!await isPathAccessible(target)) { | ||
await copyFileAsync(source, target); | ||
copied.push(`${dir}/${stripped}`); | ||
} | ||
} | ||
} | ||
return copied; | ||
} | ||
function hasExampleSuffix(name) { | ||
if (!name) { | ||
return false; | ||
} | ||
if (name === '.example') { | ||
return false; | ||
} | ||
const arr = name.split('.'); | ||
if (arr.length > 1 && arr[arr.length - 1] === 'example') { // 排除 '.example' | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
function stripExampleSuffix(name) { | ||
const arr = name.split('.'); | ||
if (arr.length > 1 && arr[arr.length - 1] === 'example') { | ||
return arr.slice(0, arr.length - 1).join('.'); | ||
} | ||
return name; | ||
} | ||
/** Return Observable<number> to check whether skip commitlint */ | ||
function isSkipCommitlint(options) { | ||
const { baseDir, COMMIT_EDITMSG, branchName, protectBranch, skipMsg, } = options; | ||
const commitFile = path.join(baseDir, COMMIT_EDITMSG); | ||
if (!COMMIT_EDITMSG) { | ||
console.warn('COMMIT_EDITMSG value blank'); | ||
return rxjs.of(1); | ||
} | ||
const protectRule$ = rxjs.from(protectBranch).pipe(operators.defaultIfEmpty()); | ||
const skipRule$ = rxjs.from(skipMsg).pipe(operators.defaultIfEmpty()); | ||
const content$ = pathAccessible(commitFile).pipe(operators.tap((path) => { | ||
if (!path) { | ||
console.warn(`COMMIT_EDITMSG file not exists: "${commitFile}"`); | ||
process.exit(1); | ||
} | ||
}), operators.mergeMap(path => readFileAsync(path, { encoding: 'utf8' })), operators.map((msg) => { | ||
const [head] = msg.split(/\n|\r\n/u); | ||
return { head, msg }; | ||
}), operators.share()); | ||
const protectTest$ = rxjs.combineLatest(rxjs.of(branchName), protectRule$).pipe(operators.map(([branch, regex]) => !!(regex && regex.test(branch))), operators.filter(matched => matched), operators.mapTo(0), // process.exit(0) | ||
operators.defaultIfEmpty(1)); | ||
const skipTest$ = rxjs.combineLatest(content$, skipRule$).pipe(operators.map(([{ head }, regex]) => !!(regex && regex.test(head))), operators.filter(matched => matched), operators.mapTo(1), // process.exit(1) | ||
operators.defaultIfEmpty(0)); | ||
const exitCode$ = rxjs.forkJoin(protectTest$, skipTest$).pipe(operators.map(([pro, skip]) => { | ||
// console.info('pro:skip', pro, skip) | ||
// eslint-disable-next-line no-bitwise | ||
return pro & skip; | ||
}), operators.defaultIfEmpty(0), // not skip commitlint | ||
operators.take(1)); | ||
return exitCode$; | ||
} | ||
Object.defineProperty(exports, 'basename', { | ||
@@ -435,3 +355,2 @@ enumerable: true, | ||
exports.fileExists = fileExists; | ||
exports.genFileFromExample = genFileFromExample; | ||
exports.genRandomInt = genRandomInt; | ||
@@ -442,3 +361,2 @@ exports.isDirExists = isDirExists; | ||
exports.isPathAccessible = isPathAccessible; | ||
exports.isSkipCommitlint = isSkipCommitlint; | ||
exports.isWin32 = isWin32; | ||
@@ -445,0 +363,0 @@ exports.mkdirAsync = mkdirAsync; |
export * from './lib/index'; | ||
export * from './lib/model'; |
@@ -6,3 +6,1 @@ export * from './asset'; | ||
export * from './helper'; | ||
export * from './init-example-file'; | ||
export * from './test-skip-commitlint'; |
@@ -6,3 +6,1 @@ export * from './asset'; | ||
export * from './helper'; | ||
export * from './init-example-file'; | ||
export * from './test-skip-commitlint'; |
@@ -1,1 +0,1 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
"use strict"; |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -50,2 +50,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@waiting/shared-types": "^1.0.0", | ||
"rxjs": "^6.5.2" | ||
@@ -88,3 +89,3 @@ }, | ||
"cov:coveralls": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc mocha && nyc report --reporter=text-lcov | coveralls", | ||
"doc": "typedoc src/index.ts src/lib/index.ts src/lib/model.ts src/lib/file.ts src/lib/utils.ts", | ||
"doc": "typedoc --includes src/", | ||
"jslint": "eslint --fix dist/**/*.js", | ||
@@ -91,0 +92,0 @@ "link_global": "npm link typescript", |
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
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
54557
2
25
778
+ Added@waiting/shared-types@^1.0.0
+ Added@waiting/shared-types@1.1.0(transitive)