@cenk1cenk2/oclif-common 1.7.1 → 1.8.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/dist/index.d.ts +8 -7
- package/dist/index.js +37 -63
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -205,14 +205,14 @@ declare class FileSystemService {
|
|
|
205
205
|
readSync(file: string): string;
|
|
206
206
|
write(file: string, data: string | Buffer, options?: fs.WriteFileOptions): Promise<void>;
|
|
207
207
|
writeSync(file: string, data: string | Buffer, options?: fs.WriteFileOptions): void;
|
|
208
|
-
append(file: string, data: string | Buffer): Promise<void>;
|
|
208
|
+
append(file: string, data: string | Buffer, options?: fs.WriteFileOptions): Promise<void>;
|
|
209
209
|
appendSync(file: string, data: string | Buffer): void;
|
|
210
|
-
remove(file: string): Promise<void>;
|
|
211
|
-
removeSync(file: string): void;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
remove(file: string, options?: fs.RmOptions): Promise<void>;
|
|
211
|
+
removeSync(file: string, options?: fs.RmOptions): void;
|
|
212
|
+
emptyDir(directory: string): Promise<void>;
|
|
213
|
+
emptyDirSync(directory: string): void;
|
|
214
|
+
mkdir(directory: string): Promise<void>;
|
|
215
|
+
mkdirSync(directory: string): void;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
interface ValidatorServiceOptions {
|
|
@@ -265,6 +265,7 @@ declare class Command<Ctx extends ListrContext = ListrContext, Config extends Ba
|
|
|
265
265
|
catch(e: Error): Promise<void>;
|
|
266
266
|
/** Gets prompt from user. */
|
|
267
267
|
prompt<T = any>(options: PromptOptions): Promise<T>;
|
|
268
|
+
exit(code?: number): void;
|
|
268
269
|
private greet;
|
|
269
270
|
}
|
|
270
271
|
|
package/dist/index.js
CHANGED
|
@@ -79,7 +79,7 @@ function pipeProcessToLogger(logger, instance, options) {
|
|
|
79
79
|
...options
|
|
80
80
|
};
|
|
81
81
|
if (options.start) {
|
|
82
|
-
logger.run(instance.spawnargs.join(" "), { level:
|
|
82
|
+
logger.run(instance.spawnargs.join(" "), { level: options.start });
|
|
83
83
|
}
|
|
84
84
|
if (instance.stdout) {
|
|
85
85
|
instance.stdout.pipe(
|
|
@@ -99,7 +99,7 @@ function pipeProcessToLogger(logger, instance, options) {
|
|
|
99
99
|
const message = `Process ended with code ${code}${signal ? ` and signal ${signal}` : ""}.`;
|
|
100
100
|
logger.debug(message);
|
|
101
101
|
if (options.end) {
|
|
102
|
-
logger.end(instance.spawnargs.join(" "), { level:
|
|
102
|
+
logger.end(instance.spawnargs.join(" "), { level: options.end });
|
|
103
103
|
}
|
|
104
104
|
if (options?.callback) {
|
|
105
105
|
options.callback();
|
|
@@ -505,8 +505,7 @@ var FileSystemService = class {
|
|
|
505
505
|
const raw = await import_fs_extra.default.readFile(file, "utf-8");
|
|
506
506
|
return raw;
|
|
507
507
|
} catch (e) {
|
|
508
|
-
|
|
509
|
-
throw e;
|
|
508
|
+
throw new Error(`Error while reading file from "${file}": ${e.message}`);
|
|
510
509
|
}
|
|
511
510
|
}
|
|
512
511
|
readSync(file) {
|
|
@@ -514,106 +513,77 @@ var FileSystemService = class {
|
|
|
514
513
|
const raw = import_fs_extra.default.readFileSync(file, "utf-8");
|
|
515
514
|
return raw;
|
|
516
515
|
} catch (e) {
|
|
517
|
-
|
|
518
|
-
throw e;
|
|
516
|
+
throw new Error(`Error while reading file from "${file}": ${e.message}`);
|
|
519
517
|
}
|
|
520
518
|
}
|
|
521
519
|
async write(file, data, options = {}) {
|
|
522
520
|
try {
|
|
523
521
|
await import_fs_extra.default.writeFile(file, data, { encoding: "utf-8", ...options });
|
|
524
522
|
} catch (e) {
|
|
525
|
-
|
|
526
|
-
throw e;
|
|
523
|
+
throw new Error(`Error while writing file to "${file}": ${e.message}`);
|
|
527
524
|
}
|
|
528
525
|
}
|
|
529
526
|
writeSync(file, data, options = {}) {
|
|
530
527
|
try {
|
|
531
528
|
import_fs_extra.default.writeFileSync(file, data, { encoding: "utf-8", ...options });
|
|
532
529
|
} catch (e) {
|
|
533
|
-
|
|
534
|
-
throw e;
|
|
530
|
+
throw new Error(`Error while writing file to "${file}": ${e.message}`);
|
|
535
531
|
}
|
|
536
532
|
}
|
|
537
|
-
async append(file, data) {
|
|
533
|
+
async append(file, data, options) {
|
|
538
534
|
try {
|
|
539
|
-
await import_fs_extra.default.appendFile(file, data);
|
|
535
|
+
await import_fs_extra.default.appendFile(file, data, options);
|
|
540
536
|
} catch (e) {
|
|
541
|
-
|
|
542
|
-
throw e;
|
|
537
|
+
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
543
538
|
}
|
|
544
539
|
}
|
|
545
540
|
appendSync(file, data) {
|
|
546
541
|
try {
|
|
547
542
|
import_fs_extra.default.appendFileSync(file, data);
|
|
548
543
|
} catch (e) {
|
|
549
|
-
|
|
550
|
-
throw e;
|
|
544
|
+
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
551
545
|
}
|
|
552
546
|
}
|
|
553
|
-
async remove(file) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
return this.removeDirectory(file);
|
|
547
|
+
async remove(file, options) {
|
|
548
|
+
try {
|
|
549
|
+
await import_fs_extra.default.rm(file, options);
|
|
550
|
+
} catch (e) {
|
|
551
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
559
552
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
} else if (stats.isDirectory()) {
|
|
567
|
-
return this.removeDirectorySync(file);
|
|
553
|
+
}
|
|
554
|
+
removeSync(file, options) {
|
|
555
|
+
try {
|
|
556
|
+
import_fs_extra.default.rmSync(file, options);
|
|
557
|
+
} catch (e) {
|
|
558
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
568
559
|
}
|
|
569
|
-
throw new Error("Not implemented!");
|
|
570
560
|
}
|
|
571
|
-
async
|
|
561
|
+
async emptyDir(directory) {
|
|
572
562
|
try {
|
|
573
|
-
|
|
574
|
-
await import_fs_extra.default.unlink(file);
|
|
575
|
-
} else {
|
|
576
|
-
throw new Error("Not a file.");
|
|
577
|
-
}
|
|
563
|
+
await import_fs_extra.default.emptyDir(directory);
|
|
578
564
|
} catch (e) {
|
|
579
|
-
|
|
580
|
-
throw e;
|
|
565
|
+
throw new Error(`Error while deleting the directory "${directory}": ${e.message}`);
|
|
581
566
|
}
|
|
582
567
|
}
|
|
583
|
-
|
|
568
|
+
emptyDirSync(directory) {
|
|
584
569
|
try {
|
|
585
|
-
|
|
586
|
-
import_fs_extra.default.unlinkSync(file);
|
|
587
|
-
} else {
|
|
588
|
-
throw new Error("Not a file.");
|
|
589
|
-
}
|
|
570
|
+
import_fs_extra.default.emptyDirSync(directory);
|
|
590
571
|
} catch (e) {
|
|
591
|
-
|
|
592
|
-
throw e;
|
|
572
|
+
throw new Error(`Error while deleting the directory "${directory}": ${e.message}`);
|
|
593
573
|
}
|
|
594
574
|
}
|
|
595
|
-
async
|
|
575
|
+
async mkdir(directory) {
|
|
596
576
|
try {
|
|
597
|
-
|
|
598
|
-
await import_fs_extra.default.emptyDir(directory);
|
|
599
|
-
} else {
|
|
600
|
-
throw new Error("Not a folder.");
|
|
601
|
-
}
|
|
577
|
+
await import_fs_extra.default.mkdirp(directory);
|
|
602
578
|
} catch (e) {
|
|
603
|
-
|
|
604
|
-
throw e;
|
|
579
|
+
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
605
580
|
}
|
|
606
581
|
}
|
|
607
|
-
|
|
582
|
+
mkdirSync(directory) {
|
|
608
583
|
try {
|
|
609
|
-
|
|
610
|
-
import_fs_extra.default.emptyDirSync(directory);
|
|
611
|
-
} else {
|
|
612
|
-
throw new Error("Not a folder.");
|
|
613
|
-
}
|
|
584
|
+
import_fs_extra.default.mkdirSync(directory);
|
|
614
585
|
} catch (e) {
|
|
615
|
-
|
|
616
|
-
throw e;
|
|
586
|
+
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
617
587
|
}
|
|
618
588
|
}
|
|
619
589
|
};
|
|
@@ -993,6 +963,10 @@ var Command = class extends import_core.Command {
|
|
|
993
963
|
throw e;
|
|
994
964
|
}
|
|
995
965
|
}
|
|
966
|
+
exit(code) {
|
|
967
|
+
this.logger.trace("Exitting with code: %d", code);
|
|
968
|
+
process.exit(code ?? 0);
|
|
969
|
+
}
|
|
996
970
|
greet() {
|
|
997
971
|
if (this.isSilent) {
|
|
998
972
|
return;
|