Skip to content

Commit

Permalink
fix: replace touch with fs.writeFIle
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar committed Oct 13, 2021
1 parent 61bbbfc commit 2d1e9be
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gogen/lib/utils/install.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import path from 'path'
import {promises as fs} from 'fs'
import boolify from './boolify'
import canUseYarn from './canUseYarn'
import shell, {SpawnOptions} from './shell'

const createFileIfNeeded = async (file: string) => {
if (!(await boolify(fs.stat(file)))) {
await fs.writeFile(file, '')
}
}

type InstallOptions = Pick<SpawnOptions, 'cwd' | 'stdio'> & {
/** install to `devDependencies` */
dev?: boolean
Expand Down Expand Up @@ -36,7 +45,7 @@ const install = async (
args.push('--silent')
}
// https://github.com/yarnpkg/berry/issues/1050#issuecomment-596659082
await shell(`touch yarn.lock`, {cwd, stdio})
await createFileIfNeeded(path.resolve(String(cwd) ?? '', 'yarn.lock'))
await shell(`yarn ${args.filter((n) => n).join(' ')}`, {cwd, stdio})
} else if (client === 'npm') {
const args = deps.length ? [...deps, dev && '--save-dev'] : []
Expand Down

0 comments on commit 2d1e9be

Please sign in to comment.