From d41a3a06462c6996c10568ec86eb0b4b1de36ae8 Mon Sep 17 00:00:00 2001 From: Alex Buijs Date: Thu, 10 Dec 2015 16:58:31 +0100 Subject: [PATCH 1/2] Don't deploy ignored items Fix for #28. Also fixes a bug where each custom ignored item replaced a default ignored item. --- dist/context.js | 4 ++-- dist/deploy.js | 11 +++++++++-- src/context.js | 3 ++- src/deploy.js | 9 +++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dist/context.js b/dist/context.js index 4a159b4..140dcef 100644 --- a/dist/context.js +++ b/dist/context.js @@ -6,7 +6,7 @@ fs = require('fs-extra'), _ = require('lodash'), ignoreFilePath = path.join(process.cwd(), '.chcpignore'), - DEFAULT_IGNORE_LIST = ['.DS_Store', 'node_modules/*', 'node_modules\\*', 'chcp.json', 'chcp.manifest', '.chcp*', '.gitignore', '.git', 'package.json']; + DEFAULT_IGNORE_LIST = ['.DS_Store', 'node_modules/*', 'node_modules\\*', 'chcp.json', 'chcp.manifest', '.chcp*', '.gitignore', '.gitkeep', '.git', 'package.json']; module.exports = { context: context @@ -46,7 +46,7 @@ } if (projectIgnore.length > 0) { - _.assign(this.__ignoredFiles, _.trim(projectIgnore).split(/\n/)); + this.__ignoredFiles = this.__ignoredFiles.concat(_.trim(projectIgnore).split(/\n/)); } return this.__ignoredFiles; diff --git a/dist/deploy.js b/dist/deploy.js index 19351dc..d08e1cf 100644 --- a/dist/deploy.js +++ b/dist/deploy.js @@ -30,7 +30,8 @@ function deploy(context) { var executeDfd = Q.defer(), config, - credentials; + credentials, + ignore = context.ignoredFiles(); try { config = fs.readFileSync(context.defaultConfig, 'utf-8'); @@ -55,11 +56,17 @@ process.exit(0); } + ignore = ignore.map(function (ignoredFile) { + return '!' + ignoredFile; + }); + // console.log('Credentials: ', credentials); // console.log('Config: ', config); + // console.log('Ignore: ', ignore); var files = readdirp({ - root: context.sourceDirectory + root: context.sourceDirectory, + fileFilter: ignore }); var uploader = s3sync({ diff --git a/src/context.js b/src/context.js index baa9d37..5c15daa 100644 --- a/src/context.js +++ b/src/context.js @@ -12,6 +12,7 @@ 'chcp.manifest', '.chcp*', '.gitignore', + '.gitkeep', '.git', 'package.json' ]; @@ -54,7 +55,7 @@ } if (projectIgnore.length > 0) { - _.assign(this.__ignoredFiles, _.trim(projectIgnore).split(/\n/)); + this.__ignoredFiles = this.__ignoredFiles.concat(_.trim(projectIgnore).split(/\n/)); } return this.__ignoredFiles; diff --git a/src/deploy.js b/src/deploy.js index f6da4a5..5b3bd02 100644 --- a/src/deploy.js +++ b/src/deploy.js @@ -28,7 +28,8 @@ function deploy(context) { var executeDfd = Q.defer(), config, - credentials; + credentials, + ignore = context.ignoredFiles(); try { config = fs.readFileSync(context.defaultConfig, 'utf-8'); @@ -53,11 +54,15 @@ process.exit(0); } + ignore = ignore.map( ignoredFile => `!${ignoredFile}` ) + // console.log('Credentials: ', credentials); // console.log('Config: ', config); + // console.log('Ignore: ', ignore); var files = readdirp({ - root: context.sourceDirectory + root: context.sourceDirectory, + fileFilter: ignore }); var uploader = s3sync({ From 9cfb471b81511d59032f3994069d41af01b4cc7b Mon Sep 17 00:00:00 2001 From: Alex Buijs Date: Thu, 10 Dec 2015 17:34:27 +0100 Subject: [PATCH 2/2] Do include the chcp* files --- dist/deploy.js | 3 +++ src/deploy.js | 1 + 2 files changed, 4 insertions(+) diff --git a/dist/deploy.js b/dist/deploy.js index d08e1cf..a0aaf72 100644 --- a/dist/deploy.js +++ b/dist/deploy.js @@ -56,6 +56,9 @@ process.exit(0); } + ignore = ignore.filter(function (ignoredFile) { + return !ignoredFile.match(/^chcp/); + }); ignore = ignore.map(function (ignoredFile) { return '!' + ignoredFile; }); diff --git a/src/deploy.js b/src/deploy.js index 5b3bd02..ce15197 100644 --- a/src/deploy.js +++ b/src/deploy.js @@ -54,6 +54,7 @@ process.exit(0); } + ignore = ignore.filter( ignoredFile => !ignoredFile.match(/^chcp/) ) ignore = ignore.map( ignoredFile => `!${ignoredFile}` ) // console.log('Credentials: ', credentials);