UNPKG

906 BJavaScriptView Raw
1const path = require('path')
2const shelljs = require('shelljs')
3
4const { version } = require('../package.json')
5const { shouldUseYarn } = require('../dist/util')
6const Project = require('../dist/create/project').default
7
8class GenerateLockfile extends Project {
9 copy () {
10 const cwd = process.cwd()
11 const { projectName, template } = this.conf
12 const lockfileDir = path.join(this.templatePath(), template, 'yarn-lockfiles')
13 shelljs.cd(cwd)
14 shelljs.rm('-rf', lockfileDir)
15 shelljs.mkdir('-p', lockfileDir)
16 shelljs.cp('-r', `${projectName}/yarn.lock`, `${lockfileDir}/${version}-yarn.lock`)
17 shelljs.rm('-rf', projectName)
18 }
19
20 start () {
21 this.write(this.copy.bind(this))
22 }
23}
24
25if (shouldUseYarn) {
26 const generateLockfile = new GenerateLockfile({
27 projectName: 'temp',
28 template: 'default',
29 typescript: false,
30 env: 'test'
31 })
32 generateLockfile.start()
33}