Skip to content

Commit 0317cb6

Browse files
authored
Merge pull request #206 from fedwiki/test-script-correction
Fix Test Script
2 parents 0b41545 + 12ccc25 commit 0317cb6

5 files changed

Lines changed: 31 additions & 34 deletions

File tree

lib/page.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,22 @@ export default argv => {
7676
// create a list of plugin pages.
7777
const pluginPages = new Map()
7878

79-
Object.keys(packageJson.dependencies)
80-
.filter(depend => depend.startsWith('wiki-plugin'))
81-
.forEach(plugin => {
82-
const pagesPath = path.join(path.dirname(require.resolve(`${plugin}/package`)), 'pages')
83-
fs.readdir(pagesPath, { withFileTypes: true }, (err, entries) => {
84-
if (err) return
85-
entries.forEach(entry => {
86-
if (entry.isFile() && !pluginPages.has(entry.name)) {
87-
pluginPages.set(entry.name, { pluginName: plugin, pluginPath: entry.parentPath })
88-
}
89-
})
79+
const dependencyPlugins = Object.keys(packageJson.dependencies).filter(depend => depend.startsWith('wiki-plugin'))
80+
const plugins = dependencyPlugins.length
81+
? dependencyPlugins
82+
: Object.keys(packageJson.devDependencies).filter(depend => depend.startsWith('wiki-plugin'))
83+
84+
plugins.forEach(plugin => {
85+
const pagesPath = path.join(path.dirname(require.resolve(`${plugin}/package`)), 'pages')
86+
fs.readdir(pagesPath, { withFileTypes: true }, (err, entries) => {
87+
if (err) return
88+
entries.forEach(entry => {
89+
if (entry.isFile() && !pluginPages.has(entry.name)) {
90+
pluginPages.set(entry.name, { pluginName: plugin, pluginPath: entry.parentPath })
91+
}
9092
})
9193
})
94+
})
9295

9396
// #### Private utility methods. ####
9497
const load_parse = (loc, cb, annotations = {}) => {

lib/server.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,17 @@ export default async argv => {
449449
})
450450
}
451451

452+
// in test (wiki-server) the plugins are listed as devDependencues, so we need to fallback to
453+
// using devDEpendencies when there are no plugins in dependencies.
454+
const dependencyPlugins = Object.keys(packageJson.dependencies).filter(depend => depend.startsWith('wiki-plugin'))
455+
const plugins = dependencyPlugins.length
456+
? dependencyPlugins
457+
: Object.keys(packageJson.devDependencies).filter(depend => depend.startsWith('wiki-plugin'))
458+
452459
Promise.all(
453-
Object.keys(packageJson.dependencies)
454-
.filter(depend => depend.startsWith('wiki-plugin'))
455-
.map(plugin => {
456-
return getPackageFactory(plugin)
457-
}),
460+
plugins.map(plugin => {
461+
return getPackageFactory(plugin)
462+
}),
458463
).then(() => res.end(JSON.stringify(factories)))
459464
})
460465

@@ -643,6 +648,10 @@ export default async argv => {
643648
} catch (e) {
644649
return res.e(e)
645650
}
651+
// Object.keys(packageJson.dependencies)
652+
// .filter(depend => depend.startsWith('wiki-plugin'))
653+
// .map(name => name.slice(12))
654+
// .then(names => res.send(names))
646655
})
647656
//{
648657
const sitemapLoc = path.join(argv.status, 'sitemap.json')

lib/sitemap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export default argv => {
233233
itself.emit('finished')
234234
}
235235
itself.isWorking = () => {
236-
working
236+
return working
237237
}
238238

239239
itself.createSitemap = pagehandler => {

package-lock.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"dependencies": {
3535
"body-parser": "^2.2.1",
3636
"client-sessions": "^0.8.0",
37-
"coffeescript": "^2.5.0",
3837
"cookie-parser": "^1.4.4",
3938
"dompurify": "^3.3.0",
4039
"errorhandler": "^1.5.1",
@@ -51,8 +50,8 @@
5150
"scripts": {
5251
"prettier:format": "prettier --write './**/*.js'",
5352
"prettier:check": "prettier --check ./**/*.js",
54-
"test": "cd test; node --test",
55-
"watch": "cd test; node --test --watch",
53+
"test": "node --test",
54+
"watch": "node --test --watch",
5655
"update-authors": "node scripts/update-authors.js"
5756
},
5857
"devDependencies": {

0 commit comments

Comments
 (0)