@cenk1cenk2/oclif-common 3.2.2 → 3.4.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 +2 -0
- package/dist/index.js +19 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -178,9 +178,11 @@ declare class LockerService<LockFile extends LockableData = LockableData> {
|
|
|
178
178
|
addUnlock(...data: UnlockData[]): void;
|
|
179
179
|
lockAll(): Promise<void>;
|
|
180
180
|
unlockAll(): Promise<void>;
|
|
181
|
+
all(): Promise<void>;
|
|
181
182
|
lock<T extends LockableData = LockableData>(...data: LockData<T>[]): Promise<void>;
|
|
182
183
|
unlock(...data: UnlockData[]): Promise<void>;
|
|
183
184
|
read(): Promise<LockFile>;
|
|
185
|
+
tryRead(): Promise<LockFile | undefined>;
|
|
184
186
|
write(data: LockFile): Promise<void>;
|
|
185
187
|
private buildPath;
|
|
186
188
|
private normalizePath;
|
package/dist/index.js
CHANGED
|
@@ -801,8 +801,12 @@ var LockerService = class {
|
|
|
801
801
|
this.toUnlock = [];
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
|
+
async all() {
|
|
805
|
+
await this.unlockAll();
|
|
806
|
+
await this.lockAll();
|
|
807
|
+
}
|
|
804
808
|
async lock(...data) {
|
|
805
|
-
let lock = await this.
|
|
809
|
+
let lock = await this.tryRead() ?? {};
|
|
806
810
|
await Promise.all(
|
|
807
811
|
data.map(async (d) => {
|
|
808
812
|
if (d?.enabled === false) {
|
|
@@ -830,7 +834,7 @@ var LockerService = class {
|
|
|
830
834
|
await this.write(lock);
|
|
831
835
|
}
|
|
832
836
|
async unlock(...data) {
|
|
833
|
-
let lock = await this.
|
|
837
|
+
let lock = await this.tryRead();
|
|
834
838
|
if (!lock) {
|
|
835
839
|
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
836
840
|
return;
|
|
@@ -855,6 +859,13 @@ var LockerService = class {
|
|
|
855
859
|
async read() {
|
|
856
860
|
return this.parser.parse(await this.fs.read(this.file));
|
|
857
861
|
}
|
|
862
|
+
async tryRead() {
|
|
863
|
+
try {
|
|
864
|
+
return this.parser.parse(await this.fs.read(this.file));
|
|
865
|
+
} catch {
|
|
866
|
+
this.logger.trace("Can not read lockfile: %s", this.file);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
858
869
|
async write(data) {
|
|
859
870
|
return this.fs.write(this.file, this.parser.stringify(data));
|
|
860
871
|
}
|
|
@@ -865,7 +876,12 @@ var LockerService = class {
|
|
|
865
876
|
return this.normalizePath(d.path);
|
|
866
877
|
}
|
|
867
878
|
normalizePath(path) {
|
|
868
|
-
|
|
879
|
+
if (Array.isArray(path)) {
|
|
880
|
+
return path;
|
|
881
|
+
} else if (typeof path === "string") {
|
|
882
|
+
return path.split(".");
|
|
883
|
+
}
|
|
884
|
+
return [];
|
|
869
885
|
}
|
|
870
886
|
};
|
|
871
887
|
__name(LockerService, "LockerService");
|