@variousjs/create 0.1.0 → 0.3.1

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/bin/copy.js CHANGED
@@ -1,48 +1,38 @@
1
1
  const fs = require('fs')
2
2
  const package = require('../package.json')
3
+ const packageLock = require('../package-lock.json')
3
4
 
4
5
  const files = ['.gitignore', 'package-lock.json', 'package.json']
5
- const { COPY_ENV } = process.env
6
6
 
7
- if (COPY_ENV === 'publish') {
8
- package.name = 'variousjs'
9
- package.version = '0.1.0'
10
- package.private = true
7
+ package.name = 'variousjs'
8
+ package.version = '0.1.0'
9
+ package.private = true
11
10
 
12
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
- const { prepublishOnly, postinstall, ...rest } = package.scripts
14
- package.scripts = rest
11
+ packageLock.name = 'variousjs'
12
+ packageLock.version = '0.1.0'
15
13
 
16
- delete package.bin
17
- delete package.publishConfig
18
- delete package.repository
19
- delete package.keywords
20
- delete package.bugs
21
- delete package.homepage
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ const { prepublishOnly, ...rest } = package.scripts
16
+ package.scripts = rest
22
17
 
23
- fs.writeFileSync('package.json.copy', JSON.stringify(package, null, 2))
24
- }
18
+ delete package.bin
19
+ delete package.publishConfig
20
+ delete package.repository
21
+ delete package.keywords
22
+ delete package.bugs
23
+ delete package.homepage
24
+
25
+ fs.writeFileSync('package.json.copy', JSON.stringify(package, null, 2))
26
+ fs.writeFileSync('package-lock.json.copy', JSON.stringify(packageLock, null, 2))
25
27
 
26
28
  files.forEach((name) => {
27
29
  const copyName = `${name}.copy`
28
30
 
29
31
  try {
30
- if (COPY_ENV === 'publish' && name !== 'package.json') {
32
+ if (name !== 'package.json' && name !== 'package-lock.json') {
31
33
  fs.copyFileSync(name, copyName, fs.constants.COPYFILE_FICLONE)
32
34
  }
33
-
34
- if (COPY_ENV === 'init') {
35
- fs.copyFileSync(copyName, name, fs.constants.COPYFILE_FICLONE)
36
- }
37
35
  } catch (e) {
38
36
  console.log(e.message)
39
37
  }
40
-
41
- if (COPY_ENV === 'init') {
42
- try {
43
- fs.unlinkSync(copyName)
44
- } catch (e) {
45
- console.log(e.message)
46
- }
47
- }
48
38
  })
package/bin/create.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const path = require('path')
4
4
  const fs = require('fs')
5
5
 
6
+ const configFiles = ['.gitignore', 'package-lock.json', 'package.json']
6
7
  const ignores = [
7
8
  '.git',
8
9
  'bin',
@@ -45,3 +46,19 @@ files.forEach(({ src, dest, destPath }) => {
45
46
  // ignore
46
47
  }
47
48
  })
49
+
50
+ configFiles.forEach((name) => {
51
+ const copyName = `${name}.copy`
52
+
53
+ try {
54
+ fs.copyFileSync(copyName, name, fs.constants.COPYFILE_FICLONE)
55
+ } catch (e) {
56
+ console.log(e.message)
57
+ }
58
+
59
+ try {
60
+ fs.unlinkSync(copyName)
61
+ } catch (e) {
62
+ console.log(e.message)
63
+ }
64
+ })