Migrate packageMetadata
Summary: _typescript_ Reviewed By: danielbuechele Differential Revision: D16782045 fbshipit-source-id: cfbabc036eb707f76a375f451ccc831b25c6d462
This commit is contained in:
committed by
Facebook Github Bot
parent
610a926611
commit
0f270c9f48
@@ -5,7 +5,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {readCurrentRevision} from '../packageMetadata.js';
|
||||
import {readCurrentRevision} from '../packageMetadata.tsx';
|
||||
|
||||
test('readCurrentRevision does not return something meaningful in dev mode', async () => {
|
||||
const ret = await readCurrentRevision();
|
||||
|
||||
@@ -20,7 +20,7 @@ import fs from 'fs';
|
||||
import uuid from 'uuid';
|
||||
import {remote} from 'electron';
|
||||
import {serialize, deserialize} from './serialization';
|
||||
import {readCurrentRevision} from './packageMetadata.js';
|
||||
import {readCurrentRevision} from './packageMetadata';
|
||||
import {tryCatchReportPlatformFailures} from './metrics';
|
||||
import {promisify} from 'util';
|
||||
import promiseTimeout from './promiseTimeout';
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import electron from 'electron';
|
||||
import lodash from 'lodash';
|
||||
import isProduction from './isProduction.tsx';
|
||||
import isProduction from './isProduction';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import {promisify} from 'util';
|
||||
@@ -17,17 +17,20 @@ const getPackageJSON = async () => {
|
||||
isProduction() && electron.remote
|
||||
? electron.remote.app.getAppPath()
|
||||
: process.cwd();
|
||||
const content = await promisify(fs.readFile)(path.join(base, 'package.json'));
|
||||
const content = await promisify(fs.readFile)(
|
||||
path.join(base, 'package.json'),
|
||||
'utf-8',
|
||||
);
|
||||
return JSON.parse(content);
|
||||
};
|
||||
|
||||
export const readCurrentRevision: () => Promise<?string> = lodash.memoize(
|
||||
async () => {
|
||||
// This is provided as part of the bundling process for headless.
|
||||
if (global.__REVISION__) {
|
||||
return global.__REVISION__;
|
||||
}
|
||||
const json = await getPackageJSON();
|
||||
return json.revision;
|
||||
},
|
||||
);
|
||||
export const readCurrentRevision: () => Promise<
|
||||
string | undefined
|
||||
> = lodash.memoize(async () => {
|
||||
// This is provided as part of the bundling process for headless.
|
||||
if (global.__REVISION__) {
|
||||
return global.__REVISION__;
|
||||
}
|
||||
const json = await getPackageJSON();
|
||||
return json.revision;
|
||||
});
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
declare module NodeJS {
|
||||
interface Global {
|
||||
__REVISION__: string | undefined;
|
||||
electronRequire: (name: string) => void;
|
||||
window: Window | undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user