@cenk1cenk2/oclif-common 3.3.0 → 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 CHANGED
@@ -178,6 +178,7 @@ 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>;
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.read() ?? {};
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.read();
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;
@@ -859,7 +863,7 @@ var LockerService = class {
859
863
  try {
860
864
  return this.parser.parse(await this.fs.read(this.file));
861
865
  } catch {
862
- this.logger.trace("Can not read file therefore not parsing: %s", this.file);
866
+ this.logger.trace("Can not read lockfile: %s", this.file);
863
867
  }
864
868
  }
865
869
  async write(data) {
@@ -872,7 +876,12 @@ var LockerService = class {
872
876
  return this.normalizePath(d.path);
873
877
  }
874
878
  normalizePath(path) {
875
- return Array.isArray(path) ? path : path.split(".");
879
+ if (Array.isArray(path)) {
880
+ return path;
881
+ } else if (typeof path === "string") {
882
+ return path.split(".");
883
+ }
884
+ return [];
876
885
  }
877
886
  };
878
887
  __name(LockerService, "LockerService");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "author": {