Skip to content

Commit

Permalink
ci: throw error when a file is missing (#242)
Browse files Browse the repository at this point in the history
fixes #242
  • Loading branch information
Joxit committed Apr 2, 2022
1 parent ba6d817 commit 772d19c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import json from '@rollup/plugin-json';
import copy from 'rollup-plugin-copy';
import copyTransform from './rollup/copy-transform';
import license from './rollup/license';
import checkOutput from './rollup/check-output';

const useServe = process.env.ROLLUP_SERVE === 'true';
const output = useServe ? '.serve' : 'dist';
Expand Down Expand Up @@ -44,11 +45,12 @@ export default [
dir: output,
name: 'DockerRegistryUI',
format: 'iife',
sourcemap: useServe
sourcemap: useServe,
},
plugins: [emptyDirectories(output)].concat(
plugins,
html({ template: () => htmlUseref('./src/index.html', { developement: useServe, production: !useServe }) })
html({ template: () => htmlUseref('./src/index.html', { developement: useServe, production: !useServe }) }),
checkOutput(output)
),
},
];
40 changes: 40 additions & 0 deletions rollup/check-output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fs from 'fs';
import path from 'path';

const files = [
'docker-registry-ui.css',
'docker-registry-ui.js',
'fonts/MaterialIcons-Regular.eot',
'fonts/MaterialIcons-Regular.svg',
'fonts/MaterialIcons-Regular.ttf',
'fonts/MaterialIcons-Regular.woff',
'fonts/MaterialIcons-Regular.woff2',
'fonts/Roboto-Bold.ttf',
'fonts/Roboto-Bold.woff',
'fonts/Roboto-Bold.woff2',
'fonts/Roboto-Light.ttf',
'fonts/Roboto-Light.woff',
'fonts/Roboto-Light.woff2',
'fonts/RobotoMono-Regular.eot',
'fonts/RobotoMono-Regular.ttf',
'fonts/RobotoMono-Regular.woff',
'fonts/RobotoMono-Regular.woff2',
'fonts/Roboto-Regular.eot',
'fonts/Roboto-Regular.ttf',
'fonts/Roboto-Regular.woff',
'fonts/Roboto-Regular.woff2',
'images/docker-logo.svg',
'index.html',
];

export default function (output) {
return {
name: 'check-output',
writeBundle: () => {
const missingFile = files.find((file) => !fs.existsSync(path.join(output, file)));
if (missingFile) {
throw new Error(`File ${missingFile} is missing after build`);
}
},
};
}

0 comments on commit 772d19c

Please sign in to comment.