Skip to content

Commit

Permalink
🐛 Fix path creation problem
Browse files Browse the repository at this point in the history
The built files don't mimic the same file structure as the source.
So running `path` with `../..` was targeting a different folder
depending in the environment.
  • Loading branch information
Yurickh committed Nov 13, 2019
1 parent 9499029 commit a54867b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/helpers/copy-template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs-extra'
import * as path from 'path'
import templateFolder from '../template-folder'

export default function copyTemplate(name: string): void {
fs.copySync(path.join(__dirname, '..', '..', 'templates', name), `./${name}`)
fs.copySync(templateFolder(name), `${process.cwd()}/${name}`)
}
6 changes: 2 additions & 4 deletions src/helpers/lint-staged-rc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs-extra'
import * as path from 'path'
import installDependencies from './install-dependencies'
import templateFolder from '../template-folder'

const targetFile = './.lintstagedrc.json'

Expand All @@ -14,9 +14,7 @@ const getBaseConfig = (): Config =>
fs.existsSync(targetFile) ? fs.readJSONSync(targetFile) : {}

const getTargetConfig = (feature: Feature): Config =>
fs.readJSONSync(
path.join(__dirname, '..', 'templates', `${feature}.lintstagedrc.json`),
)
fs.readJSONSync(templateFolder(`${feature}.lintstagedrc.json`))

const mergeJSON = async (
featureConfig: Config,
Expand Down
5 changes: 5 additions & 0 deletions src/template-folder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as path from 'path'

export default function templateFolder(file: string): string {
return path.join(__dirname, '..', 'templates', file)
}

0 comments on commit a54867b

Please sign in to comment.