Skip to content

Commit

Permalink
XXX UPDATE WIP: CB-12397 fix .gitignore for plugins & platforms
Browse files Browse the repository at this point in the history
XXX TODO: USE fs-extra function instead,
XXX WAITING FOR apache#14 to be merged

NOTE: This implementation is a workaround for the
npm .gitignore/.npmignore behavior discussed in:
- npm/npm#1862
- npm/npm#3763
- npm/npm#7252
  • Loading branch information
Christopher J. Brody committed May 30, 2018
1 parent f4b752d commit ba0c258
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ module.exports = function (dir, optionalId, optionalName, cfg, extEvents) {
fs.mkdirSync(dir);
}

// CB-12397 add .gitignore for plugins & platforms
// to generated app
// (use stock .npmignore for ignore file)
// NOTE: This is a workaround solution for the existing
// npm .gitignore/.npmignore behavior discussed in:
// npm/npm#1862
// npm/npm#3763
// npm/npm#7252
const ignoreStockPath =
path.join(require('cordova-app-hello-world').dirname, '.npmignore');

try {
// Copy files from template to project
if (cfg.lib.www.template) {
Expand Down Expand Up @@ -263,6 +274,16 @@ module.exports = function (dir, optionalId, optionalName, cfg, extEvents) {

pkgjson.version = DEFAULT_VERSION;
fs.writeFileSync(pkgjsonPath, JSON.stringify(pkgjson, null, 4), 'utf8');

// XXX TODO USE fs-extra function instead,
// XXX WAITING FOR apache/cordova-create#14 to be merged
// CB-12397 add .gitignore for plugins & platforms
// to generated app
// XXX GONE:
shell.cp(ignoreStockPath, path.join(dir, '.gitignore'));
/* ** XXX TODO:
fs.copySync(ignoreStockPath, path.join(dir, '.gitignore'));
// */
}

// Create basic project structure.
Expand Down
8 changes: 4 additions & 4 deletions spec/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ describe('create end-to-end', function () {
// Check if package.json exists.
expect(path.join(project, 'package.json')).toExist();

// [CB-12397] Check that .gitignore does not exist
expect(path.join(project, '.gitignore')).not.toExist();
// [CB-12397] Check that .gitignore exists
expect(path.join(project, '.gitignore')).toExist();
// [CB-12397] Check that .npmignore exists
expect(path.join(project, '.npmignore')).toExist();

Expand All @@ -164,8 +164,8 @@ describe('create end-to-end', function () {
expect(path.join(project, 'www', 'js')).not.toExist();
expect(path.join(project, 'www', 'js', 'index.js')).not.toExist();

// [CB-12397] Check that .gitignore does not exist
expect(path.join(project, '.gitignore')).not.toExist();
// [CB-12397] Check that .gitignore exists
expect(path.join(project, '.gitignore')).toExist();
// [CB-12397] Check that .npmignore does not exist
expect(path.join(project, '.npmignore')).not.toExist();

Expand Down

0 comments on commit ba0c258

Please sign in to comment.