@open-audio-stack/core 0.0.8 → 0.0.9
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/build/helpers/file.d.ts +1 -0
- package/build/helpers/file.js +5 -0
- package/build/index-browser.d.ts +1 -0
- package/build/index-browser.js +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/package.json +1 -1
package/build/helpers/file.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare function fileDelete(filePath: string): boolean | void;
|
|
|
19
19
|
export declare function fileExec(filePath: string): void;
|
|
20
20
|
export declare function fileExists(filePath: string): boolean;
|
|
21
21
|
export declare function fileJsonCreate(filePath: string, data: object): void;
|
|
22
|
+
export declare function fileHash(filePath: string, algorithm?: string): string;
|
|
22
23
|
export declare function fileMove(filePath: string, newPath: string): void | boolean;
|
|
23
24
|
export declare function fileOpen(filePath: string): Buffer;
|
|
24
25
|
export declare function fileRead(filePath: string): Buffer;
|
package/build/helpers/file.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AdmZip from 'adm-zip';
|
|
2
2
|
import { execSync } from 'child_process';
|
|
3
3
|
import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'fs';
|
|
4
|
+
import { createHash } from 'crypto';
|
|
4
5
|
import { globSync } from 'glob';
|
|
5
6
|
import { moveSync } from 'fs-extra/esm';
|
|
6
7
|
import os from 'os';
|
|
@@ -125,6 +126,10 @@ export function fileExists(filePath) {
|
|
|
125
126
|
export function fileJsonCreate(filePath, data) {
|
|
126
127
|
return fileCreate(filePath, JSON.stringify(data, null, 2));
|
|
127
128
|
}
|
|
129
|
+
export function fileHash(filePath, algorithm = 'sha256') {
|
|
130
|
+
const fileData = fileReadString(filePath);
|
|
131
|
+
return createHash(algorithm).update(fileData, 'utf8').digest('hex');
|
|
132
|
+
}
|
|
128
133
|
export function fileMove(filePath, newPath) {
|
|
129
134
|
if (fileExists(filePath)) {
|
|
130
135
|
console.log('-', filePath);
|
package/build/index-browser.d.ts
CHANGED
package/build/index-browser.js
CHANGED
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED