Skip to content

Commit

Permalink
Avoid overriding package.json
Browse files Browse the repository at this point in the history
Resolves #45.
  • Loading branch information
danielbayley committed Oct 15, 2020
1 parent 1a70c81 commit befccc5
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions jest-preset.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import fs from 'fs'
import path from 'path'
import {compile, helpers as h, FILE_EXTENSIONS} from 'coffeescript'
import package_json, {jest} from './package'#.json

{name} = path.parse __filename
coffee = FILE_EXTENSIONS.map (ext) => ext[1..]
glob = "*.@(#{coffee.join '|'})"

package_json.main = jest.preset = "./#{name}"
[staged] = Object.values package_json['lint-staged']
package_json['lint-staged'] = [glob]: staged
delete jest.rootDir
fs.writeFileSync 'package.json', JSON.stringify package_json, null, 2

if describe?
override = describe
Expand All @@ -20,7 +11,7 @@ if describe?

module.exports =
moduleFileExtensions: ['js', 'json', coffee...]
testMatch: ["<rootDir>/*@(test|spec)?(s){/**/,}#{glob}"]
testMatch: ["<rootDir>/*@(test|spec)?(s){/**/,}@(#{coffee.join '|'})"]
testPathIgnorePatterns: ['node_modules', 'fixtures']
transform: [coffee.join '|']: __filename
setupFilesAfterEnv: [__filename ]
Expand Down

0 comments on commit befccc5

Please sign in to comment.