2 Commits

Author SHA1 Message Date
Niels Leenheer
477a52e779 fix: use setEncoding() and read() for crypto.createHash instead of digest() (#11) 2020-11-20 02:05:59 -08:00
Samuel Attard
107823fc2c fix: use realpath when scanning app files 2020-11-19 14:43:08 -08:00
2 changed files with 4 additions and 2 deletions

View File

@@ -78,7 +78,7 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
const uniqueToX64: string[] = []; const uniqueToX64: string[] = [];
const uniqueToArm64: string[] = []; const uniqueToArm64: string[] = [];
const x64Files = await getAllAppFiles(await fs.realpath(tmpApp)); const x64Files = await getAllAppFiles(await fs.realpath(tmpApp));
const arm64Files = await getAllAppFiles(opts.arm64AppPath); const arm64Files = await getAllAppFiles(await fs.realpath(opts.arm64AppPath));
for (const file of dupedFiles(x64Files)) { for (const file of dupedFiles(x64Files)) {
if (!arm64Files.some((f) => f.relativePath === file.relativePath)) if (!arm64Files.some((f) => f.relativePath === file.relativePath))
@@ -252,6 +252,7 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
} }
d('moving final universal app to target destination'); d('moving final universal app to target destination');
await fs.mkdirp(path.dirname(opts.outAppPath));
await spawn('mv', [tmpApp, opts.outAppPath]); await spawn('mv', [tmpApp, opts.outAppPath]);
} catch (err) { } catch (err) {
throw err; throw err;

View File

@@ -5,11 +5,12 @@ import { d } from './debug';
export const sha = async (filePath: string) => { export const sha = async (filePath: string) => {
d('hashing', filePath); d('hashing', filePath);
const hash = crypto.createHash('sha256'); const hash = crypto.createHash('sha256');
hash.setEncoding('hex');
const fileStream = fs.createReadStream(filePath); const fileStream = fs.createReadStream(filePath);
fileStream.pipe(hash); fileStream.pipe(hash);
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
fileStream.on('end', () => resolve()); fileStream.on('end', () => resolve());
fileStream.on('error', (err) => reject(err)); fileStream.on('error', (err) => reject(err));
}); });
return hash.digest('hex'); return hash.read();
}; };