create-sip 0.15.1 → 0.16.0

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.
Files changed (2) hide show
  1. package/expressapi/op +29 -0
  2. package/package.json +1 -1
package/expressapi/op CHANGED
@@ -5,6 +5,7 @@ import { generateApiKey } from 'generate-api-key'
5
5
  import bcrypt from 'bcryptjs';
6
6
  import path from 'path';
7
7
  import { read } from 'read'
8
+ import { start } from 'repl';
8
9
 
9
10
  if(process.argv.length == 3 && process.argv[2] == 'help') {
10
11
  console.log('Usable commands:');
@@ -75,6 +76,11 @@ async function copyController(className) {
75
76
 
76
77
  const src = 'templates/controllerTemplate.js'
77
78
  const dest = `app/controllers/${lowerName}controller.js`
79
+
80
+ if(await startCheckIfFileExists(dest)) {
81
+ process.exit(1);
82
+ }
83
+
78
84
  await fse.copy(src, dest)
79
85
 
80
86
  replace({
@@ -99,6 +105,10 @@ async function copyModel(className) {
99
105
  const src = 'templates/modelTemplate.js'
100
106
  const dest = `app/models/${lowerName}.js`
101
107
 
108
+ if(await startCheckIfFileExists(dest)) {
109
+ process.exit(1);
110
+ }
111
+
102
112
  await fse.copy(src, dest)
103
113
 
104
114
  replace({
@@ -113,6 +123,25 @@ async function copyModel(className) {
113
123
  })
114
124
  }
115
125
 
126
+ async function checkIfFileExists(filePath) {
127
+ return await fsp.access(filePath)
128
+ .then(() => true)
129
+ .catch(() => false);
130
+ }
131
+
132
+ async function startCheckIfFileExists(filePath) {
133
+ return await checkIfFileExists(filePath)
134
+ .then(exists => {
135
+ if (exists) {
136
+ console.log(`The file ${filePath} exists!`);
137
+ return true;
138
+ } else {
139
+ return false;
140
+ }
141
+ })
142
+ .catch(error => console.log(error));
143
+ }
144
+
116
145
  function capitalizeFirstLetter(word) {
117
146
  return word.charAt(0).toUpperCase() + word.slice(1);
118
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sip",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "create-sip": "create-sip.js"