Skip to content

Commit 5db331c

Browse files
authored
feat: add support for excluding files and improve image build (#150)
Signed-off-by: Denis Golovin <[email protected]>
1 parent 07af835 commit 5db331c

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

.extfiles

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ icon.png
44
redhat-icon.woff2
55
README.md
66
dist/**
7-
www/**
7+
www/**
8+
!**/yarn.lock

Containerfile

+1-7
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,4 @@ LABEL org.opencontainers.image.title="Red Hat Account" \
2222
org.opencontainers.image.vendor="Red Hat" \
2323
io.podman-desktop.api.version=">= 1.9.0"
2424

25-
COPY package.json /extension/
26-
COPY LICENSE /extension/
27-
COPY icon.png /extension/
28-
COPY redhat-icon.woff2 /extension/
29-
COPY README.md /extension/
30-
COPY dist /extension/dist
31-
COPY www /extension/www
25+
COPY builtin/redhat-authentication.cdix /extension

scripts/build.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const extFiles = path.resolve(__dirname, '../.extfiles');
3333
const fileStream = fs.createReadStream(extFiles, { encoding: 'utf8' });
3434

3535
const includedFiles = [];
36+
const excludedFiles = [];
3637

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

5455
byline(fileStream)
5556
.on('data', line => {
56-
includedFiles.push(line);
57+
line.startsWith('!') ? excludedFiles.push(line.substring(1)) : includedFiles.push(line);
5758
})
5859
.on('error', () => {
5960
throw new Error('Error reading .extfiles');
@@ -62,7 +63,7 @@ cproc.exec('yarn add [email protected] --cwd .', { cwd: './dist' }, (error, stdo
6263
includedFiles.push(zipDirectory); // add destination dir
6364
mkdirp.sync(zipDirectory);
6465
console.log(`Copying files to ${zipDirectory}`);
65-
cp(includedFiles, error => {
66+
cp(includedFiles, { exclude: excludedFiles }, error => {
6667
if (error) {
6768
throw new Error('Error copying files', error);
6869
}

0 commit comments

Comments
 (0)