Skip to content

Commit

Permalink
Docsify bug workaround (#643)
Browse files Browse the repository at this point in the history
Ensure that `strip-indent@3` is floated to the top of `node_modules` to fix a bug where `docsify-server-renderer` can require that package (which it doesn't have as a declared dependency) and receive version 4 instead, which is an ESM module.
  • Loading branch information
jpage-godaddy authored Dec 21, 2023
1 parent 6361455 commit b32e8ac
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/gasket-plugin-docsify/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# `@gasket/plugin-docsify`

- Workaround to fix `gasket docs` command caused by a [docsify bug](https://github.com/docsifyjs/docsify/issues/2345)

### 6.34.4

- Upgrade eslint-plugin-unicorn v43 ([#436])
Expand Down
6 changes: 6 additions & 0 deletions packages/gasket-plugin-docsify/lib/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function create(_gasket, { pkg }) {
// Workaround for https://github.com/docsifyjs/docsify/issues/2345
pkg.add('dependencies', {
'strip-indent': require('docsify/package.json').dependencies['strip-indent']
});
};
2 changes: 2 additions & 0 deletions packages/gasket-plugin-docsify/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const create = require('./create');
const docsView = require('./docs-view');

module.exports = {
name: require('../package').name,
hooks: {
create,
docsView,
metadata(gasket, meta) {
return {
Expand Down
15 changes: 15 additions & 0 deletions packages/gasket-plugin-docsify/test/create.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { hooks: { create } } = require('../lib');
const docsifyPackage = require('docsify/package.json');

describe('The create hook', () => {
it('adds a strip-indent dependency to work around a docsify bug', function () {
const context = { pkg: { add: jest.fn() } };

create({}, context);

expect(context.pkg.add).toHaveBeenCalledWith(
'dependencies',
{ 'strip-indent': docsifyPackage.dependencies['strip-indent'] }
);
});
});
1 change: 1 addition & 0 deletions packages/gasket-plugin-docsify/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('Plugin', function () {

it('has expected hooks', () => {
const expected = [
'create',
'docsView',
'metadata'
];
Expand Down

0 comments on commit b32e8ac

Please sign in to comment.