From e8c90f68d83ded7b72dda60fbaecf637cfa855ef Mon Sep 17 00:00:00 2001 From: Gabriel Garcia Date: Fri, 4 Jan 2019 06:25:55 -0300 Subject: [PATCH] Add filter for files passed as parameter to not be ignored (#313) * add filter for files * consider ignore files without eol at the end --- src/commands/apm_cmds/publish.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/commands/apm_cmds/publish.js b/src/commands/apm_cmds/publish.js index f5a8f22e3..6e845713f 100644 --- a/src/commands/apm_cmds/publish.js +++ b/src/commands/apm_cmds/publish.js @@ -220,14 +220,21 @@ async function prepareFilesForPublishing( const filter = ignore().add(ignorePatterns) const projectRoot = findProjectRoot() + function createFilter(files, ignorePath) { + let f = fs.readFileSync(ignorePath).toString() + files.forEach(file => { + f = f.concat(`\n!${file}`) + }) + return f + } + const ipfsignorePath = path.resolve(projectRoot, '.ipfsignore') if (pathExistsSync(ipfsignorePath)) { - filter.add(fs.readFileSync(ipfsignorePath).toString()) + filter.add(createFilter(files, ipfsignorePath)) } else { const gitignorePath = path.resolve(projectRoot, '.gitignore') - if (pathExistsSync(gitignorePath)) { - filter.add(fs.readFileSync(gitignorePath).toString()) + filter.add(createFilter(files, gitignorePath)) } }