@cenk1cenk2/oclif-common 1.7.2 → 1.8.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.
- package/dist/index.d.ts +5 -7
- package/dist/index.js +20 -64
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -205,14 +205,12 @@ 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
|
-
removeDirectory(directory: string): Promise<void>;
|
|
215
|
-
removeDirectorySync(directory: string): void;
|
|
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;
|
|
216
214
|
}
|
|
217
215
|
|
|
218
216
|
interface ValidatorServiceOptions {
|
package/dist/index.js
CHANGED
|
@@ -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,63 @@ 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;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
async remove(file) {
|
|
554
|
-
const stats = this.stats(file);
|
|
555
|
-
if (stats.isFile()) {
|
|
556
|
-
return this.removeFile(file);
|
|
557
|
-
} else if (stats.isDirectory()) {
|
|
558
|
-
return this.removeDirectory(file);
|
|
559
|
-
}
|
|
560
|
-
throw new Error("Not implemented!");
|
|
561
|
-
}
|
|
562
|
-
removeSync(file) {
|
|
563
|
-
const stats = this.stats(file);
|
|
564
|
-
if (stats.isFile()) {
|
|
565
|
-
return this.removeFileSync(file);
|
|
566
|
-
} else if (stats.isDirectory()) {
|
|
567
|
-
return this.removeDirectorySync(file);
|
|
544
|
+
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
568
545
|
}
|
|
569
|
-
throw new Error("Not implemented!");
|
|
570
546
|
}
|
|
571
|
-
async
|
|
547
|
+
async remove(file, options) {
|
|
572
548
|
try {
|
|
573
|
-
|
|
574
|
-
await import_fs_extra.default.unlink(file);
|
|
575
|
-
} else {
|
|
576
|
-
throw new Error("Not a file.");
|
|
577
|
-
}
|
|
549
|
+
await import_fs_extra.default.rm(file, options);
|
|
578
550
|
} catch (e) {
|
|
579
|
-
|
|
580
|
-
throw e;
|
|
551
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
581
552
|
}
|
|
582
553
|
}
|
|
583
|
-
|
|
554
|
+
removeSync(file, options) {
|
|
584
555
|
try {
|
|
585
|
-
|
|
586
|
-
import_fs_extra.default.unlinkSync(file);
|
|
587
|
-
} else {
|
|
588
|
-
throw new Error("Not a file.");
|
|
589
|
-
}
|
|
556
|
+
import_fs_extra.default.rmSync(file, options);
|
|
590
557
|
} catch (e) {
|
|
591
|
-
|
|
592
|
-
throw e;
|
|
558
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
593
559
|
}
|
|
594
560
|
}
|
|
595
|
-
async
|
|
561
|
+
async emptyDir(directory) {
|
|
596
562
|
try {
|
|
597
|
-
|
|
598
|
-
await import_fs_extra.default.emptyDir(directory);
|
|
599
|
-
} else {
|
|
600
|
-
throw new Error("Not a folder.");
|
|
601
|
-
}
|
|
563
|
+
await import_fs_extra.default.emptyDir(directory);
|
|
602
564
|
} catch (e) {
|
|
603
|
-
|
|
604
|
-
throw e;
|
|
565
|
+
throw new Error(`Error while deleting the directory "${directory}": ${e.message}`);
|
|
605
566
|
}
|
|
606
567
|
}
|
|
607
|
-
|
|
568
|
+
emptyDirSync(directory) {
|
|
608
569
|
try {
|
|
609
|
-
|
|
610
|
-
import_fs_extra.default.emptyDirSync(directory);
|
|
611
|
-
} else {
|
|
612
|
-
throw new Error("Not a folder.");
|
|
613
|
-
}
|
|
570
|
+
import_fs_extra.default.emptyDirSync(directory);
|
|
614
571
|
} catch (e) {
|
|
615
|
-
|
|
616
|
-
throw e;
|
|
572
|
+
throw new Error(`Error while deleting the directory "${directory}": ${e.message}`);
|
|
617
573
|
}
|
|
618
574
|
}
|
|
619
575
|
};
|