Skip to content

Commit

Permalink
Merge pull request #131 from happo/remove-project-json
Browse files Browse the repository at this point in the history
Remove project.json after Storybook build
  • Loading branch information
trotzig authored Oct 8, 2024
2 parents 68c5782 + fbb92f7 commit a5f4274
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ jobs:
- run: yarn -v
- run: yarn install --immutable
- run: yarn lint
- run: yarn build
- run: yarn test
- run: yarn build && npx -p happo.io happo-ci-github-actions
- run: npx -p happo.io happo-ci-github-actions
- run: yarn build-local-storybook && HAPPO_USE_PREBUILT_PACKAGE=yes HAPPO_PROJECT=storybook8-prebuilt npx -p happo.io happo-ci-github-actions

storybook7:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.happo-out
.out
/addon.js
/constants.js
/decorator.js
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ function buildStorybook({ configDir, staticDir, outputDir }) {

spawned.on('exit', (code) => {
if (code === 0) {
try {
fs.unlinkSync(path.join(outputDir, 'project.json'));
} catch (error) {
console.warn(
`Ignoring error when attempting to remove project.json: ${error}`,
);
}
resolve();
} else {
reject(new Error('Failed to build static storybook package'));
Expand Down
11 changes: 11 additions & 0 deletions test/index-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fs = require('fs');
const path = require('path');

const happoStorybookPlugin = require('../index');

jest.setTimeout(60000);

it('removes the project.json after build', async () => {
const result = await happoStorybookPlugin().generateStaticPackage();
expect(fs.existsSync(path.join(result.path, 'project.json'))).toBeFalsy();
});

0 comments on commit a5f4274

Please sign in to comment.