Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit a86d133

Browse files
committed
WIP ignoreFiles argument
1 parent 7b9a738 commit a86d133

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/jobs/create.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const chalk = require('chalk');
3030
* @param {string} [params.projectId] - The poject id of an existing project for this job. Note: if projectId is specified, the project parameter cannot be specified.
3131
* @param {string} [params.command] - An optional command to run within the workspace or container.
3232
* @param {string} [params.workspace] - An optional path to a workspace, or link to a git repository to upload and merge with the container. If a zip file name is provided it is uploaded instead. If no workspace is provided the current directory is zipped up and transferred. If the workspace is 'none', no workspace is merged and the container is run as-is. To download a git repository provide an https repository link and optionally prefix it with 'git+', e.g. 'https://github.com/MyProjects/MyRepo.git'. If the 'git+' prefix is not specified, it is added at the time of download to the job runner machine. S3 links are also supported using the schema 's3://bucketname/objectname'.
33+
* @param {string} [params.ignoreFiles] - An optional reference to files that should be excluded from workspace upload. Files/folders to be ignored.
3334
* @param {string} [params.codeCommit] - An optional reference to git commit hash if local workspace is a git repository. Found at runtime.
3435
* @param {string} [params.dataset] - An optional reference to a dataset to be merged with the container.
3536
* @param {string} [params.registryUsername] - An optional username for accessing an image hosted on a private container registry. Note: you must specify this option every time a private image is specified for the container.
@@ -411,13 +412,33 @@ function create(params, cb) {
411412
throw err;
412413
}
413414
});
415+
416+
// exclude user supplied --ignoreFiles as well: folders or files
417+
if (params.ignoreFiles) {
418+
if (typeof params.ignoreFiles === 'string') {
419+
var ignoreFilesArray = params.ignoreFiles.split(',')
420+
ignoreFilesArray.forEach(element => {
421+
fs.lstat(params.workspace + '/' + element, (err, stats) => {
422+
if(err) {
423+
var err = new Error('Error: ignoreFiles argument not found: aborting');
424+
return ifCliPrintErrorOnly(err);
425+
}
426+
})
427+
element = '**/' + element
428+
});
429+
} else {
430+
var err = new Error('Error: ignoreFiles argument should be folder or file in string format');
431+
return ifCliPrintErrorOnly(err);
432+
}
433+
}
434+
414435

415436
archive.pipe(output);
416437
if (stat.isDirectory()) {
417438
// include . prefixed folders and files but exclude .git and .gitignore folders and files
418439
archive.glob('**/*', {
419440
cwd: params.workspace,
420-
ignore: ['**/.git/**', '**/.git', '**/.gitignore'],
441+
ignore: ['**/.git/**', '**/.git', '**/.gitignore'].concat(ignoreFilesArray),
421442
dot: true,
422443
}, false);
423444
} else {

0 commit comments

Comments
 (0)