Skip to content

Commit

Permalink
tagged plugin exports also set plugin core name exports
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Nov 30, 2020
1 parent 9c35005 commit f3e73c6
Show file tree
Hide file tree
Showing 6 changed files with 2,542 additions and 2,450 deletions.
18 changes: 11 additions & 7 deletions lib/plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/plugin.js.map

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions lib/plugin.ts
Expand Up @@ -272,6 +272,7 @@ function make_tasks(): any {
},


// Handle plugin meta data returned by plugin define function
meta: (spec: TaskSpec) => {
let seneca: any = spec.ctx.seneca
let plugin: any = spec.data.plugin
Expand All @@ -286,7 +287,12 @@ function make_tasks(): any {
Object.keys(exportmap).forEach(k => {
let v: any = exportmap[k]
if (void 0 !== v) {
let exportname = plugin.fullname + '/' + k
let exportfullname = plugin.fullname + '/' + k
exports[exportfullname] = v

// Also provide exports on untagged plugin name. This is the
// standard name that other plugins use
let exportname = plugin.name + '/' + k
exports[exportname] = v
}
})
Expand All @@ -298,13 +304,7 @@ function make_tasks(): any {
Array.isArray(meta.order.plugin) ? meta.order.plugin :
[meta.order.plugin]

//console.log('AAA', spec.task.name, tasks)
//try {
seneca.order.plugin.add(tasks)
//}
//catch (e) {
// console.log(e)
//}
delete meta.order.plugin
}
}
Expand Down Expand Up @@ -771,6 +771,11 @@ function make_intern() {
},

seneca_export: (tr: any, ctx: any, data: any): any => {
// NOTE/plugin/774a: when loading multiple tagged plugins,
// last plugin wins the plugin name on the exports. This is
// consistent with general Seneca principal that plugin load
// order is significant, as later plugins override earlier
// action patterns. Thus later plugins override exports too.
Object.assign(data.exports, tr.out.exports)
Object.assign(ctx.seneca.private$.exports, tr.out.exports)
return { stop: false }
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -72,6 +72,7 @@
"watch": "tsc -w -d",
"build": "tsc -d",
"test": "lab -v -P test -L -t 90 --sourcemaps --transform node_modules/lab-transform-typescript -r console -o stdout -r html -o test/coverage.html",
"test-some": "lab -v -P test --sourcemaps --transform node_modules/lab-transform-typescript -g",
"coveralls": "lab -s -P test -r lcov | coveralls",
"coverage": "lab -v -P test -L -t 90 -r html > docs/coverage.html",
"smoke": "node test/stubs/launch.js",
Expand Down

0 comments on commit f3e73c6

Please sign in to comment.