-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support object form for banner/footer/intro/outro
- Loading branch information
1 parent
3bc931c
commit c031c04
Showing
5 changed files
with
164 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const acorn = require('acorn'); | ||
|
||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
const code = fs.readFileSync(ID_MAIN, 'utf8'); | ||
|
||
const hooks = ['banner', 'footer', 'intro', 'outro']; | ||
|
||
const plugins = []; | ||
addPlugin(null); | ||
addPlugin('pre'); | ||
addPlugin('post'); | ||
addPlugin('post'); | ||
addPlugin('pre'); | ||
addPlugin(undefined); | ||
function addPlugin(order) { | ||
const name = `${order}-${(plugins.length >> 1) + 1}`; | ||
const plugin = { name }; | ||
const stringPlugin = { name: `string-${name}` }; | ||
for (const hook of hooks) { | ||
plugin[hook] = { | ||
order, | ||
handler: () => `// ${hook}-${name}` | ||
}; | ||
stringPlugin[hook] = { | ||
order, | ||
handler: `// ${hook}-string-${name}` | ||
}; | ||
} | ||
plugins.push(plugin, stringPlugin); | ||
} | ||
|
||
module.exports = { | ||
description: 'allows to enforce addon order', | ||
options: { | ||
plugins | ||
} | ||
}; |
Oops, something went wrong.