Skip to content

Commit 8f54dae

Browse files
committed
fix: use local gts path for generated tsconfig.json
Currently the global gts path is used when `gts init` is done using a globally installed `gts`, which is a usual workflow.
1 parent 817c885 commit 8f54dae

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/init.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,8 @@ async function generateTsConfig(options: Options): Promise<void> {
152152
}
153153
}
154154

155-
// typescript expects relative paths to start with './'.
156-
const baseConfig = './' +
157-
path.relative(
158-
options.targetRootDir,
159-
path.resolve(options.gtsRootDir, 'tsconfig-google.json'));
160155
const tsconfig = formatJson({
161-
extends: baseConfig,
156+
extends: './node_modules/gts/tsconfig-google.json',
162157
compilerOptions: {rootDir: '.', outDir: 'build'},
163158
include: ['src/*.ts', 'src/**/*.ts', 'test/*.ts', 'test/**/*.ts'],
164159
exclude: ['node_modules']

test/test-kitchen.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ test.serial('init', async t => {
8585
`npx -p ${stagingPath}/gts.tgz --ignore-existing gts init -n`,
8686
execOpts);
8787
}
88-
fs.accessSync(`${stagingPath}/kitchen/tsconfig.json`);
89-
t.pass();
88+
const tsconfigPath = `${stagingPath}/kitchen/tsconfig.json`;
89+
fs.accessSync(tsconfigPath);
90+
91+
// The `extends` field must use the local gts path.
92+
const tsconfigJson = fs.readFileSync(tsconfigPath, 'utf8');
93+
const tsconfig = JSON.parse(tsconfigJson);
94+
t.deepEqual(tsconfig.extends, './node_modules/gts/tsconfig-google.json');
9095
});
9196

9297
test.serial('use as a non-locally installed module', async t => {

0 commit comments

Comments
 (0)