create-packer 1.20.0 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  # testing
9
9
  coverage/
10
+ __test__
10
11
 
11
12
  # production
12
13
  build/
package/bin/createTemp.js CHANGED
@@ -12,7 +12,7 @@ const fs_1 = require("fs");
12
12
  const cwd = process.cwd();
13
13
  const command = utils_1.onGenCommand();
14
14
  const excludes = ['node_modules', 'yarn-error.log', 'dist'];
15
- const tempRoot = path.join(__dirname, '../../template');
15
+ const tempRoot = path.join(__dirname, '../template');
16
16
  const tempInfoList = utils_1.genTemplateInfoList(tempRoot);
17
17
  function copyTempFile(tempPath, output) {
18
18
  fsExtra.readdirSync(tempPath).map(name => {
@@ -37,7 +37,7 @@ async function createTemp(dirname) {
37
37
  choices: tempInfoList.map(o => o.name)
38
38
  }
39
39
  ]);
40
- const tempInfo = tempInfoList.find(o => o.name === answer.temp);
40
+ let tempInfo = tempInfoList.find(o => o.name === answer.temp);
41
41
  if (tempInfo.children) {
42
42
  answer = await inquirer.prompt([
43
43
  {
@@ -47,6 +47,7 @@ async function createTemp(dirname) {
47
47
  choices: tempInfo.children.map(o => o.name)
48
48
  }
49
49
  ]);
50
+ tempInfo = tempInfo.children.find(o => o.name === answer.temp);
50
51
  }
51
52
  const creating = ora(chalk.yellow('Creating...\n')).start();
52
53
  const output = path.join(cwd, isCurrent ? '' : dirname);
@@ -56,8 +57,7 @@ async function createTemp(dirname) {
56
57
  if (!isCurrent) {
57
58
  fsExtra.mkdirSync(output);
58
59
  }
59
- const tempPath = path.join(tempRoot, answer.temp);
60
- copyTempFile(tempPath, output);
60
+ copyTempFile(tempInfo.src, output);
61
61
  createTempEnd(output);
62
62
  creating.succeed();
63
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -10,7 +10,7 @@ import { existsSync } from 'fs'
10
10
  const cwd = process.cwd()
11
11
  const command = onGenCommand()
12
12
  const excludes = ['node_modules', 'yarn-error.log', 'dist']
13
- const tempRoot = path.join(__dirname, '../../template')
13
+ const tempRoot = path.join(__dirname, '../template')
14
14
  const tempInfoList = genTemplateInfoList(tempRoot)
15
15
 
16
16
  function copyTempFile(tempPath, output) {
@@ -37,7 +37,7 @@ export async function createTemp(dirname: string) {
37
37
  choices: tempInfoList.map(o => o.name)
38
38
  }
39
39
  ])
40
- const tempInfo = tempInfoList.find(o => o.name === answer.temp)
40
+ let tempInfo = tempInfoList.find(o => o.name === answer.temp)
41
41
  if (tempInfo.children) {
42
42
  answer = await inquirer.prompt([
43
43
  {
@@ -47,6 +47,7 @@ export async function createTemp(dirname: string) {
47
47
  choices: tempInfo.children.map(o => o.name)
48
48
  }
49
49
  ])
50
+ tempInfo = tempInfo.children.find(o => o.name === answer.temp)
50
51
  }
51
52
  const creating = ora(chalk.yellow('Creating...\n')).start()
52
53
  const output = path.join(cwd, isCurrent ? '' : dirname)
@@ -56,8 +57,7 @@ export async function createTemp(dirname: string) {
56
57
  if (!isCurrent) {
57
58
  fsExtra.mkdirSync(output)
58
59
  }
59
- const tempPath = path.join(tempRoot, answer.temp)
60
- copyTempFile(tempPath, output)
60
+ copyTempFile(tempInfo.src, output)
61
61
  createTempEnd(output)
62
62
  creating.succeed()
63
63
  }