Skip to content

Feat/sgcrc#3

Merged
JPeer264 merged 16 commits intomasterfrom
feat/sgcrc
Mar 15, 2017
Merged

Feat/sgcrc#3
JPeer264 merged 16 commits intomasterfrom
feat/sgcrc

Conversation

@aichbauer
Copy link
Collaborator

Added all types that we discussed.

  • Add: Files added
  • Chore: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) and moving files
  • CI: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • Docs: Documentation only changes
  • Feat: A new feature
  • Fix: A bug fix
  • Perf: A code change that improves performance
  • Refactor: A code change that neither fixes a bug nor adds a feature
  • Style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • Test: Adding missing tests or correcting existing tests

@aichbauer aichbauer requested a review from JPeer264 March 14, 2017 18:03
@coveralls
Copy link

coveralls commented Mar 14, 2017

Coverage Status

Coverage increased (+7.8%) to 88.889% when pulling a7d3108 on feat/sgcrc into d2e2779 on master.

@aichbauer
Copy link
Collaborator Author

Do we need a type Add:? I think we should always use a more meaningful type.

Copy link
Owner

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do prefer over Add:?

lib/getConfig.js Outdated
let configObject = json.readToObjSync(pathString);

if (!configObject) {
if (configObject) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be !configObject. If altPath or cwd/.sgcrc does not exist it should read the package.json

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, how about:

let package = json.readToObjSync(path.join(cwd, 'package.json'));
configObject = typeof package === 'object' ? package.sgc : package;

package.json Outdated
{
"emoji": ":white_check_mark:",
"prefix": "Test:",
"description": "Adding missing tests or correcting existing tests"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json and test/fixtures/ .sgcrc just need one or two "types" - these are just for testing, so we can keep it small 😊

.sgcrc_default are the default types the user actually see, if there is no .sgcrc or (package.json).sgc available - so this is fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is true.

How can we test the second if stmt for branch coverage?

If there is a sgc, present in the package.json we never get into the second stmt.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about the same, the only thing I thought of is to remove the sgc in package.json temporarily.

In the tests it could be like following:

  • copy package.json to package.json.back
  • modify the original package.json
  • test
  • rm original package.json
  • mv package.json.back to package.json

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should temporary add the sgc in the package.json. Because by default it should use the .sgcrc_default and not only one type we just have in the package.json for testing purposes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will always use .sgcrc_default as default if the user did not specify any config files - the difference is process.cwd() and __dirname. But we can add it temporarily - which would be easier to manage.

Easier because we will take the config from test/fixtures/.sgcrc and add it to the package.json object. So there will be just one file to change if there would be an issue. 👍

@aichbauer
Copy link
Collaborator Author

Files added is not really meaningful.

All of the time when you add files you do this because you add docs, features, or some of the other types.

@JPeer264
Copy link
Owner

Yap exactly: we got Feat: instead. We can change that

@coveralls
Copy link

coveralls commented Mar 14, 2017

Coverage Status

Coverage decreased (-7.06%) to 78.125% when pulling 7c08852 on feat/sgcrc into b97541b on master.

@aichbauer aichbauer requested a review from JPeer264 March 14, 2017 22:47
}).then(() => {
// restore package.json from package.json.back
fs.rename(cwd + '/package.json.back', cwd + '/package.json');
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite confusing for a test with a quite long promise chain. I would suggest to use fs-extra and use its sync methods, as test perfomance is not an issue right now but readability is. Methods such as: moveSync(), writeFileSync() (not fs-extra), removeSync() , ...

fs-extra

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update!

fs.rename(cwd + '/package.json.back', cwd + '/package.json');
});
fs.createReadStream(cwd + '/package.json')
.pipe(fs.createWriteStream(cwd + '/package.json.back'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I am picky 😅, but this can be shortened to:

fs.copySync(`${cwd} /package.json`, `${cwd} /package.json.back`);

fs.writeFileSync(cwd + '/package.json', JSON.stringify(packageJson));
t.deepEqual(getConfig(), sgcrc);
fs.unlinkSync(cwd + '/package.json');
fs.renameSync(cwd + '/package.json.back', cwd + '/package.json');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally forgot to change the directory for the linting. You might get some errors - can you change the directory tests in (package.json).scripts.lint to test?

from

"lint": "eslint lib tests",

to

"lint": "eslint lib test",

@coveralls
Copy link

coveralls commented Mar 15, 2017

Coverage Status

Coverage decreased (-35.2%) to 50.0% when pulling 72fdf1a on feat/sgcrc into b97541b on master.

@JPeer264 JPeer264 merged this pull request into master Mar 15, 2017
@JPeer264
Copy link
Owner

Thanks @rudolfsonjunior

@aichbauer aichbauer deleted the feat/sgcrc branch March 15, 2017 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants