UNPKG

1.09 kBPlain TextView Raw
1import { resolve as resolvePath } from 'path';
2import getPackageData from './get-package-data';
3import getDependencies from './get-dependencies';
4import getDevDependencies from './get-dev-dependecies';
5import install from './install';
6import { IPostInstallDistTag, PackagePath } from './types';
7
8const { distTag: distTagPath } = PackagePath;
9
10export default async function ({ distTag, workingDirectory }: IPostInstallDistTag) {
11 const packagePath = resolvePath(
12 workingDirectory,
13 'package'
14 );
15 const packageDistTagPath = `${packagePath}.${distTagPath}`;
16 const packageDistTag = await getPackageData({
17 path: packageDistTagPath
18 }).catch(() => '') as string;
19 const dependencies = distTag === packageDistTag && getDependencies({
20 path: packagePath
21 }) || '';
22 const devDependencies = dependencies && getDevDependencies({
23 path: packagePath
24 }) || '';
25
26 dependencies && await await install({
27 workingDirectory,
28 dependencies: [
29 dependencies,
30 devDependencies
31 ].join(' ')
32 });
33}
\No newline at end of file