utilium 0.5.1 → 0.5.3

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/fs.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- type fs = typeof import('fs');
2
- declare let fs: fs;
3
- export declare function whenDefaultFSDone(): Promise<void>;
4
- export declare function useFS(_fs: fs): void;
5
1
  export declare abstract class FileMap<V> implements Map<string, V> {
6
2
  protected readonly path: string;
7
3
  get [Symbol.toStringTag](): string;
@@ -67,4 +63,3 @@ export declare class FolderMap extends FileMap<string> {
67
63
  set(key: string, value: string): this;
68
64
  }
69
65
  export declare function gitCommitHash(repo?: string): string;
70
- export {};
package/dist/fs.js CHANGED
@@ -1,12 +1,5 @@
1
1
  import { isJSON } from './objects.js';
2
- let fs;
3
- const defaultFS = import('fs').then(_ => (fs = _));
4
- export async function whenDefaultFSDone() {
5
- await defaultFS;
6
- }
7
- export function useFS(_fs) {
8
- fs = _fs;
9
- }
2
+ import * as fs from 'fs';
10
3
  export class FileMap {
11
4
  path;
12
5
  get [Symbol.toStringTag]() {
@@ -17,9 +10,6 @@ export class FileMap {
17
10
  if (!path) {
18
11
  throw new ReferenceError('No path specified');
19
12
  }
20
- if (!fs) {
21
- throw new ReferenceError('No filesystem API');
22
- }
23
13
  }
24
14
  get size() {
25
15
  return this._map.size;
@@ -154,7 +144,7 @@ export class FolderMap extends FileMap {
154
144
  export function gitCommitHash(repo = '.') {
155
145
  repo = repo.replaceAll(/\/+/g, '/').replaceAll(/\/$/g, '');
156
146
  const rev = fs
157
- .readFileSync(repo + '.git/HEAD')
147
+ .readFileSync(repo + '/.git/HEAD')
158
148
  .toString()
159
149
  .trim();
160
150
  if (rev.indexOf(':') === -1) {
@@ -162,7 +152,7 @@ export function gitCommitHash(repo = '.') {
162
152
  }
163
153
  else {
164
154
  return fs
165
- .readFileSync(repo + '.git/' + rev.substring(5))
155
+ .readFileSync(repo + '/.git/' + rev.substring(5))
166
156
  .toString()
167
157
  .trim();
168
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Typescript utilies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/fs.ts CHANGED
@@ -1,18 +1,5 @@
1
1
  import { isJSON } from './objects.js';
2
-
3
- type fs = typeof import('fs');
4
-
5
- let fs: fs;
6
-
7
- const defaultFS = import('fs').then(_ => (fs = _));
8
-
9
- export async function whenDefaultFSDone(): Promise<void> {
10
- await defaultFS;
11
- }
12
-
13
- export function useFS(_fs: fs): void {
14
- fs = _fs;
15
- }
2
+ import * as fs from 'fs';
16
3
 
17
4
  export abstract class FileMap<V> implements Map<string, V> {
18
5
  public get [Symbol.toStringTag](): string {
@@ -23,10 +10,6 @@ export abstract class FileMap<V> implements Map<string, V> {
23
10
  if (!path) {
24
11
  throw new ReferenceError('No path specified');
25
12
  }
26
-
27
- if (!fs) {
28
- throw new ReferenceError('No filesystem API');
29
- }
30
13
  }
31
14
 
32
15
  protected abstract readonly _map: Map<string, V>;
@@ -220,14 +203,14 @@ export class FolderMap extends FileMap<string> {
220
203
  export function gitCommitHash(repo: string = '.'): string {
221
204
  repo = repo.replaceAll(/\/+/g, '/').replaceAll(/\/$/g, '');
222
205
  const rev = fs
223
- .readFileSync(repo + '.git/HEAD')
206
+ .readFileSync(repo + '/.git/HEAD')
224
207
  .toString()
225
208
  .trim();
226
209
  if (rev.indexOf(':') === -1) {
227
210
  return rev;
228
211
  } else {
229
212
  return fs
230
- .readFileSync(repo + '.git/' + rev.substring(5))
213
+ .readFileSync(repo + '/.git/' + rev.substring(5))
231
214
  .toString()
232
215
  .trim();
233
216
  }