@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.
Files changed (2) hide show
  1. package/index.js +42 -30
  2. 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
- if (!directoryToTarball || directoryToTarball.length === 0) {
164
- throw new Error('directoryToTarball is required')
165
- }
166
- if (!outputDirectory || outputDirectory.length === 0) {
167
- throw new Error('outputDirectory is required')
168
- }
169
- if (!tarballName || tarballName.length === 0) {
170
- throw new Error('tarballName is required')
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
- const tarballPath = path.join(outputDirectory, tarballName)
175
+ const tarballPath = path.join(outputDirectory, tarballName)
174
176
 
175
- console.log('directory to create tarball from: ' + directoryToTarball)
176
- console.log('output will be: ' + tarballPath)
177
+ console.log('directory to create tarball from: ' + directoryToTarball)
178
+ console.log('output will be: ' + tarballPath)
177
179
 
178
- let normalizedDirectoryToTarball = !!cwd ? path.join(cwd, directoryToTarball) : directoryToTarball
180
+ let normalizedDirectoryToTarball = !!cwd ? path.join(cwd, directoryToTarball) : directoryToTarball
179
181
 
180
- if (!fs.existsSync(normalizedDirectoryToTarball)) {
181
- throw new Error('error: dirToTarball directory does not exist: ' + normalizedDirectoryToTarball)
182
- }
182
+ if (!fs.existsSync(normalizedDirectoryToTarball)) {
183
+ throw new Error('error: dirToTarball directory does not exist: ' + normalizedDirectoryToTarball)
184
+ }
183
185
 
184
- if (!fs.existsSync(outputDirectory)) {
185
- fs.mkdirSync(outputDirectory)
186
- } else {
187
- if (fs.existsSync(tarballPath)) {
188
- fs.unlinkSync(tarballPath)
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
- let options = { gzip: true, file: tarballPath }
193
- if (!!cwd) {
194
- options.cwd = cwd
195
- }
194
+ let options = { gzip: true, file: tarballPath }
195
+ if (!!cwd) {
196
+ options.cwd = cwd
197
+ }
196
198
 
197
- tar.c(options, [directoryToTarball])
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikeyt23/node-cli-utils",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Some node cli utility functions",
5
5
  "author": "Mike Thompson",
6
6
  "license": "MIT",