@mikeyt23/node-cli-utils 1.4.0 → 1.4.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/index.js +42 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -160,41 +160,53 @@ exports.defaultSpawnOptions = {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
async function createTarball(directoryToTarball, outputDirectory, tarballName, cwd = '') {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
try {
|
|
165
|
+
if (!directoryToTarball || directoryToTarball.length === 0) {
|
|
166
|
+
throw new Error('directoryToTarball is required')
|
|
167
|
+
}
|
|
168
|
+
if (!outputDirectory || outputDirectory.length === 0) {
|
|
169
|
+
throw new Error('outputDirectory is required')
|
|
170
|
+
}
|
|
171
|
+
if (!tarballName || tarballName.length === 0) {
|
|
172
|
+
throw new Error('tarballName is required')
|
|
173
|
+
}
|
|
172
174
|
|
|
173
|
-
|
|
175
|
+
const tarballPath = path.join(outputDirectory, tarballName)
|
|
174
176
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
console.log('directory to create tarball from: ' + directoryToTarball)
|
|
178
|
+
console.log('output will be: ' + tarballPath)
|
|
177
179
|
|
|
178
|
-
|
|
180
|
+
let normalizedDirectoryToTarball = !!cwd ? path.join(cwd, directoryToTarball) : directoryToTarball
|
|
179
181
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
if (!fs.existsSync(normalizedDirectoryToTarball)) {
|
|
183
|
+
throw new Error('error: dirToTarball directory does not exist: ' + normalizedDirectoryToTarball)
|
|
184
|
+
}
|
|
183
185
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
if (!fs.existsSync(outputDirectory)) {
|
|
187
|
+
fs.mkdirSync(outputDirectory)
|
|
188
|
+
} else {
|
|
189
|
+
if (fs.existsSync(tarballPath)) {
|
|
190
|
+
fs.unlinkSync(tarballPath)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
191
193
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
let options = { gzip: true, file: tarballPath }
|
|
195
|
+
if (!!cwd) {
|
|
196
|
+
options.cwd = cwd
|
|
197
|
+
}
|
|
196
198
|
|
|
197
|
-
|
|
199
|
+
tar.c(options, [directoryToTarball])
|
|
200
|
+
.then(() => {
|
|
201
|
+
resolve()
|
|
202
|
+
})
|
|
203
|
+
.catch(err => {
|
|
204
|
+
reject(err)
|
|
205
|
+
})
|
|
206
|
+
} catch (err) {
|
|
207
|
+
reject(err)
|
|
208
|
+
}
|
|
209
|
+
})
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
async function dockerCompose(command, projectName, dockerRelativeDirectory = 'docker', detached = false) {
|
|
@@ -371,7 +383,7 @@ async function dotnetDbAddMigrationBoilerplate(dbContextName, relativeDbMigrator
|
|
|
371
383
|
|
|
372
384
|
console.log(`Checking for generated C# file in directory: ${dirPath}`)
|
|
373
385
|
|
|
374
|
-
const filenames = fs.readdirSync(dirPath).filter(fn => fn.endsWith(`${migrationName}.cs`))
|
|
386
|
+
const filenames = fs.readdirSync(dirPath).filter(fn => fn.endsWith(`${migrationName}.cs`))
|
|
375
387
|
if (!filenames || filenames.length === 0) {
|
|
376
388
|
console.log(`Unable to add boilerplate - could not find auto generated file in directory: ${dirPath}`)
|
|
377
389
|
}
|
|
@@ -568,7 +580,7 @@ async function winUninstallCert(urlOrSubject) {
|
|
|
568
580
|
|
|
569
581
|
console.log('******************************\n* Requires admin permissions *\n******************************')
|
|
570
582
|
|
|
571
|
-
const psCommand = `$env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine'); Get-ChildItem Cert:\\LocalMachine\\Root | Where-Object { $_.Subject -match '${urlOrSubject}' } | Remove-Item
|
|
583
|
+
const psCommand = `$env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine'); Get-ChildItem Cert:\\LocalMachine\\Root | Where-Object { $_.Subject -match '${urlOrSubject}' } | Remove-Item`
|
|
572
584
|
|
|
573
585
|
await waitForProcess(spawn('powershell', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', psCommand]))
|
|
574
586
|
}
|