generated from redhat-developer/new-project-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for excluding files and improve image build (#150)
Signed-off-by: Denis Golovin <[email protected]>
- Loading branch information
Showing
3 changed files
with
6 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ icon.png | |
redhat-icon.woff2 | ||
README.md | ||
dist/** | ||
www/** | ||
www/** | ||
!**/yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) { | ||
|
@@ -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'); | ||
|
@@ -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); | ||
} | ||
|