Skip to content

fix: use local gts path for generated tsconfig.json #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2018

Conversation

jinwoo
Copy link
Member

@jinwoo jinwoo commented Jan 11, 2018

Currently the global gts path is used when gts init is done using a
globally installed gts, which is a usual workflow.

@jinwoo jinwoo requested review from ofrobots and a team January 11, 2018 01:18
@jinwoo
Copy link
Member Author

jinwoo commented Jan 11, 2018

One test will fail, which is being fixed by #112

@jinwoo
Copy link
Member Author

jinwoo commented Jan 11, 2018

This fixes #113.

Currently the global gts path is used when `gts init` is done using a
globally installed `gts`, which is a usual workflow.
const opts = {cwd: `${tmpDir.name}/kitchen`};
// It's important to use `-n` here because we don't want to overwrite
// the version of gts installed, as it will trigger the npm install.
await simpleExecp(`${GTS} init -n`, opts);
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed -n to -y because a local gts must be installed so that the gts check below can find the tsconfig-google.json file.

@jinwoo
Copy link
Member Author

jinwoo commented Jan 11, 2018

As we discussed, I moved the test to 'use as a non-locally installed module'.

@codecov-io
Copy link

codecov-io commented Jan 11, 2018

Codecov Report

Merging #114 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage    96.6%   96.63%   +0.03%     
==========================================
  Files          10       10              
  Lines         324      327       +3     
  Branches       19       19              
==========================================
+ Hits          313      316       +3     
  Misses         11       11
Impacted Files Coverage Δ
test/test-kitchen.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 817c885...f1b1ad2. Read the comment docs.

const tsconfig = formatJson({
extends: baseConfig,
extends: './node_modules/gts/tsconfig-google.json',
Copy link

@DominicKramer DominicKramer Jan 11, 2018

Choose a reason for hiding this comment

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

Should path.join be used instead of using / directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we should have a different value here depending on on which platform the source code is generated, right?

Choose a reason for hiding this comment

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

I'm not sure. I would expect tsconfig to be like package.json where we can always use /, but we should probably make sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Windows has always supported / as a path separator as well as \. So I don't see any issues with this if we consider all the current major OS's.

Choose a reason for hiding this comment

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

Ok sounds good.

await simpleExecp(`${GTS} init -n`, opts);
await simpleExecp(`${GTS} init -y`, opts);
// The `extends` field must use the local gts path.
const tsconfigJson =

Choose a reason for hiding this comment

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

nit: Could you use pify to promisify readFile so that you can await the readFile? Also, should you be using path.join here and in the t.deepEqual line?

Copy link
Member Author

Choose a reason for hiding this comment

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

This test file uses lots of ...Sync functions. I agree that using async functions is better but since this is a test file, I think we'd better make the code more consistent. WDYT?

Choose a reason for hiding this comment

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

I agree its not that big of a deal since its a test file, especially if there are a lot of places where *Sync functions are used. If we wanted to make them async, it would probably be best as a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants