1 | import { resolve as resolvePath } from 'path';
|
2 | import getPackageData from './get-package-data';
|
3 | import getDependencies from './get-dependencies';
|
4 | import getDevDependencies from './get-dev-dependecies';
|
5 | import install from './install';
|
6 | import { IPostInstallDistTag, PackagePath } from './types';
|
7 |
|
8 | const { distTag: distTagPath } = PackagePath;
|
9 |
|
10 | export 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 |