@dtsgenerator/replace-namespace
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -25,2 +25,1 @@ { | ||
} | ||
14
index.js
@@ -7,7 +7,7 @@ "use strict"; | ||
meta: { | ||
description: 'Replace the namespace names.' | ||
description: 'Replace the namespace names.', | ||
}, | ||
create: create | ||
postProcess: postProcess, | ||
}; | ||
function create(pluginContext) { | ||
function postProcess(pluginContext) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -62,3 +62,3 @@ var config, mapping; | ||
value: value, | ||
children: [] | ||
children: [], | ||
}; | ||
@@ -129,3 +129,3 @@ local.push(map); | ||
value: key, | ||
children: [] | ||
children: [], | ||
}; | ||
@@ -141,3 +141,3 @@ local.children.push(work); | ||
value: value, | ||
children: [] | ||
children: [], | ||
}); | ||
@@ -186,3 +186,3 @@ } | ||
value: '', | ||
children: [] | ||
children: [], | ||
}; | ||
@@ -189,0 +189,0 @@ function replaceModuleName(statements) { |
28
index.ts
@@ -15,5 +15,5 @@ import { Plugin, PluginContext } from 'dtsgenerator'; | ||
meta: { | ||
description: 'Replace the namespace names.' | ||
description: 'Replace the namespace names.', | ||
}, | ||
create | ||
postProcess, | ||
}; | ||
@@ -29,3 +29,3 @@ | ||
async function create( | ||
async function postProcess( | ||
pluginContext: PluginContext | ||
@@ -77,3 +77,3 @@ ): Promise<ts.TransformerFactory<ts.SourceFile> | undefined> { | ||
const value = getValue(c, level); | ||
let map = local.find(m => m.key === key); | ||
let map = local.find((m) => m.key === key); | ||
if (map == null) { | ||
@@ -83,3 +83,3 @@ map = { | ||
value, | ||
children: [] | ||
children: [], | ||
}; | ||
@@ -106,4 +106,4 @@ local.push(map); | ||
result | ||
.filter(map => map.key === true || map.key === p) | ||
.forEach(map => { | ||
.filter((map) => map.key === true || map.key === p) | ||
.forEach((map) => { | ||
work = work.concat(map.children); | ||
@@ -123,3 +123,3 @@ }); | ||
} | ||
return converted.children.find(c => c.key === key); | ||
return converted.children.find((c) => c.key === key); | ||
} | ||
@@ -133,3 +133,3 @@ function setConverted( | ||
let local = converted; | ||
path.forEach(key => { | ||
path.forEach((key) => { | ||
let work = getConvertedChild(local, key); | ||
@@ -140,3 +140,3 @@ if (work == null) { | ||
value: key, | ||
children: [] | ||
children: [], | ||
}; | ||
@@ -152,3 +152,3 @@ local.children.push(work); | ||
value, | ||
children: [] | ||
children: [], | ||
}); | ||
@@ -188,3 +188,3 @@ } else { | ||
value: '', | ||
children: [] | ||
children: [], | ||
}; | ||
@@ -202,3 +202,3 @@ | ||
const map = maps.filter( | ||
m => m.key === true || m.key === name.text | ||
(m) => m.key === true || m.key === name.text | ||
); | ||
@@ -213,3 +213,3 @@ if (map.length === 0) { | ||
if (dec.body != null && ts.isModuleBlock(dec.body)) { | ||
dec.body.statements.forEach(s => result.push(s)); | ||
dec.body.statements.forEach((s) => result.push(s)); | ||
} | ||
@@ -216,0 +216,0 @@ } else if (Array.isArray(value)) { |
{ | ||
"name": "@dtsgenerator/replace-namespace", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "replace the output namespace", | ||
@@ -38,14 +38,14 @@ "main": "index.js", | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^13.9.1", | ||
"@typescript-eslint/eslint-plugin": "^2.24.0", | ||
"@typescript-eslint/parser": "^2.24.0", | ||
"@types/node": "^13.9.3", | ||
"@typescript-eslint/eslint-plugin": "^2.25.0", | ||
"@typescript-eslint/parser": "^2.25.0", | ||
"cross-env": "^7.0.2", | ||
"dtsgenerator": "^2.5.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"mocha": "^7.1.0", | ||
"mocha": "^7.1.1", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.19.1", | ||
"ts-node": "^8.6.2", | ||
"prettier": "^2.0.2", | ||
"ts-node": "^8.8.1", | ||
"typescript": "^3.8.3" | ||
@@ -52,0 +52,0 @@ }, |
@@ -14,3 +14,17 @@ # @dtsgenerator/replace-namespace | ||
TBD | ||
`.dtsgenrc.json` | ||
```json | ||
{ | ||
"plugins": { | ||
"@dtsgenerator/replace-namespace": { | ||
"map": [ | ||
{ | ||
"from": ["path1", "path2"], | ||
"to": ["replaced"] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
@@ -29,8 +43,7 @@ # Configuration | ||
| key | description | | ||
|-----|-------------| | ||
| map | the mapping of replacing. | | ||
| map.*n* | the mapping definition. | | ||
| map.*n*.from | the definition of from name. if this value is true, it treated as wildcard . | | ||
| map.*n*.to | the definition of to name. | | ||
| key | type | description | | ||
|-----|------|-------------| | ||
| map | Array of object | the mapping of replacing. | | ||
| map.*n*.from | `Array<string | boolean>` | the definition of from name. if this value is true, it treated as wildcard . | | ||
| map.*n*.to | `Array<string | boolean>` | the definition of to name. | | ||
@@ -37,0 +50,0 @@ |
32993
76