Skip to content

Commit

Permalink
Add JSONC support
Browse files Browse the repository at this point in the history
  • Loading branch information
braebo committed Jul 21, 2021
1 parent 9ff9f01 commit 2a124df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ npm init svelte@next

Once that is set up, run this command in your project directory to set up Jest:

> ❗️ __When running with TypeScript support enabled, remove comments within `tsconfig.json` or the adder will fail. This is a known limitation of [Preset](https://usepreset.dev/), as it relies upon JSON.parse.__
```sh
npx apply rossyman/svelte-add-jest # --no-ssh
```
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@rossyman/svelte-add-jest",
"version": "1.1.1",
"version": "1.1.2",
"description": "SvelteKit adder for Jest unit testing",
"license": "MIT",
"keywords": [
Expand All @@ -20,6 +20,7 @@
],
"preset": "preset.ts",
"devDependencies": {
"apply": "^0.2.13"
"apply": "^0.2.13",
"comment-json": "^4.1.0"
}
}
11 changes: 5 additions & 6 deletions preset.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { assign, parse, stringify } from 'comment-json';
import { Preset, color } from 'apply';

type Dependencies = {
Expand Down Expand Up @@ -187,12 +188,10 @@ class SvelteJestAdder extends Adder {
.withTitle('Enabling Jest DOM Support')
.if(() => this.getConfiguration('jest-dom'));

Preset
.editJson('tsconfig.json').merge({
exclude: ['src/**/*.spec.ts']
})
.withTitle('Modifying TypeScript config for project')
.if(() => this.getConfiguration('ts'));
Preset.edit('tsconfig.json').update((content) =>
stringify(assign(parse(content), { exclude: ['src/**/*.spec.ts'] }), null, 4))
.withTitle('Modifying TypeScript config for project')
.if(() => this.getConfiguration('ts'));

Preset
.editJson('jest.config.json').merge({
Expand Down

0 comments on commit 2a124df

Please sign in to comment.