Skip to content

Commit

Permalink
cleanup reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Nov 14, 2019
1 parent b9bd1c8 commit 7c8f35d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/private-build-infra/addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
*/

import { has } from 'require';
import POSSIBLE_PACKAGES from './available-packages';
import AVAILABLE_PACKAGES from './available-packages';

type PackageSettings = Record<keyof typeof POSSIBLE_PACKAGES, boolean>;
type PackageSettings = {
[key in keyof typeof AVAILABLE_PACKAGES]: boolean;
};

const PACKAGES = Object.keys(POSSIBLE_PACKAGES).reduce((obj, name) => {
const NAME = POSSIBLE_PACKAGES[name];
obj[NAME] = has(name) || false;
return obj;
}, {}) as PackageSettings;
const PACKAGES = {} as PackageSettings;
Object.keys(AVAILABLE_PACKAGES).forEach(name => {
const NAME = AVAILABLE_PACKAGES[name];
PACKAGES[NAME] = has(name) || false;
});

export const HAS_EMBER_DATA_PACKAGE = PACKAGES.HAS_EMBER_DATA_PACKAGE;
export const HAS_STORE_PACKAGE = PACKAGES.HAS_STORE_PACKAGE;
Expand Down

0 comments on commit 7c8f35d

Please sign in to comment.