@amory/core
Advanced tools
Comparing version 2018.8.31-3 to 2018.8.31-4
47
index.js
@@ -8,2 +8,16 @@ #!/usr/bin/env node | ||
const onError = (error) => { | ||
switch (error.toString ()) { | ||
case "Error: Invalid arguments to tap(options: Object, fn: function)": | ||
console.error (`Export a "name" property from each plugin.\n`) | ||
break | ||
case "TypeError: Cannot destructure property `config` of 'undefined' or 'null'.": | ||
console.error (`Add to "package.json":\n\n "amory": { "apis": [], "plugins": [] },\n`) | ||
break | ||
default: | ||
console.error (error) | ||
break | ||
} | ||
} | ||
class AmoryCore { | ||
@@ -26,8 +40,13 @@ constructor (options = {}) { | ||
this.plugins, | ||
async (plugin) => | ||
plugin[api] && | ||
this.hooks[api].tap ( | ||
plugin.name, | ||
await plugin[api] ({ ... options, ... this }, plugin.options) | ||
) | ||
async (plugin) => { | ||
try { | ||
plugin[api] && | ||
this.hooks[api].tap ( | ||
plugin.name, | ||
await plugin[api] ({ ... options, ... this }, plugin.options) | ||
) | ||
} catch (error) { | ||
onError (error) | ||
} | ||
} | ||
)) | ||
@@ -44,16 +63,6 @@ } | ||
["markup", "script"].map ((stage) => { | ||
const define = { stage } | ||
return new AmoryCore ({ apis, define, plugins }).run () | ||
}) | ||
["markup", "script"].map ((stage) => | ||
new AmoryCore ({ apis, "define": { stage }, plugins }).run ()) | ||
} catch (error) { | ||
switch (error.toString ()) { | ||
case "TypeError: Cannot destructure property `config` of 'undefined' or 'null'.": | ||
console.error (`Add configuration to "package.json":\n\n "amory": { "apis": [], "plugins": [] },\n`) | ||
break | ||
default: | ||
console.error (error) | ||
break | ||
} | ||
onError (error) | ||
} | ||
@@ -60,0 +69,0 @@ } |
@@ -28,3 +28,3 @@ { | ||
"repository": "https://github.com/ptb/amory/tree/master/core", | ||
"version": "2018.8.31-3" | ||
"version": "2018.8.31-4" | ||
} |
2451
60