Skip to content

Commit

Permalink
feat: add support for excluding files and improve image build (#150)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Golovin <[email protected]>
  • Loading branch information
dgolovin authored Jun 3, 2024
1 parent 07af835 commit 5db331c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .extfiles
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ icon.png
redhat-icon.woff2
README.md
dist/**
www/**
www/**
!**/yarn.lock
8 changes: 1 addition & 7 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,4 @@ LABEL org.opencontainers.image.title="Red Hat Account" \
org.opencontainers.image.vendor="Red Hat" \
io.podman-desktop.api.version=">= 1.9.0"

COPY package.json /extension/
COPY LICENSE /extension/
COPY icon.png /extension/
COPY redhat-icon.woff2 /extension/
COPY README.md /extension/
COPY dist /extension/dist
COPY www /extension/www
COPY builtin/redhat-authentication.cdix /extension
5 changes: 3 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const extFiles = path.resolve(__dirname, '../.extfiles');
const fileStream = fs.createReadStream(extFiles, { encoding: 'utf8' });

const includedFiles = [];
const excludedFiles = [];

// remove the .cdix file before zipping
if (fs.existsSync(destFile)) {
Expand All @@ -53,7 +54,7 @@ cproc.exec('yarn add [email protected] --cwd .', { cwd: './dist' }, (error, stdo

byline(fileStream)
.on('data', line => {
includedFiles.push(line);
line.startsWith('!') ? excludedFiles.push(line.substring(1)) : includedFiles.push(line);
})
.on('error', () => {
throw new Error('Error reading .extfiles');
Expand All @@ -62,7 +63,7 @@ cproc.exec('yarn add [email protected] --cwd .', { cwd: './dist' }, (error, stdo
includedFiles.push(zipDirectory); // add destination dir
mkdirp.sync(zipDirectory);
console.log(`Copying files to ${zipDirectory}`);
cp(includedFiles, error => {
cp(includedFiles, { exclude: excludedFiles }, error => {
if (error) {
throw new Error('Error copying files', error);
}
Expand Down

0 comments on commit 5db331c

Please sign in to comment.