Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Add back --prefix when installing dependencies #1262

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cli/domain/handle-dependencies/install-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default function installCompiler(
dependency,
installPath: componentPath,
save: false,
silent: true
silent: true,
usePrefix: false
};

npm.installDependency(npmOptions, err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default function installMissingDependencies(
dependencies: missing,
installPath: path.resolve('.'),
save: false,
silent: true
silent: true,
usePrefix: true
};

npm.installDependencies(npmOptions, err => {
Expand Down
3 changes: 2 additions & 1 deletion src/cli/domain/init-template/install-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default function installTemplate(
dependency: compiler,
installPath: componentPath,
isDev: true,
save: true
save: true,
usePrefix: false
};

logger.log(strings.messages.cli.installCompiler(compiler));
Expand Down
19 changes: 17 additions & 2 deletions src/utils/npm-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ const buildInstallCommand = (options: {
installPath: string;
save?: boolean;
isDev?: boolean;
usePrefix: boolean;
}) => {
const args = ['install'];

if (options.usePrefix) {
args.push('--prefix', options.installPath);
}

if (options.save) {
args.push('--save-exact');
args.push(options.isDev ? '--save-dev' : '--save');
Expand Down Expand Up @@ -54,7 +59,12 @@ export const init = (
};

export const installDependencies = (
options: { dependencies: string[]; installPath: string; silent: boolean },
options: {
dependencies: string[];
installPath: string;
silent: boolean;
usePrefix: boolean;
},
callback: Callback<{ dest: string }, string | number>
): void => {
const { dependencies, installPath, silent } = options;
Expand All @@ -75,7 +85,12 @@ export const installDependencies = (
};

export const installDependency = (
options: { dependency: string; installPath: string; silent?: boolean },
options: {
dependency: string;
installPath: string;
silent?: boolean;
usePrefix: boolean;
},
callback: Callback<{ dest: string }, string | number>
): void => {
const { dependency, installPath, silent } = options;
Expand Down
3 changes: 2 additions & 1 deletion test/unit/cli-domain-handle-dependencies-install-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ describe('cli : domain : handle-dependencies : install-compiler', () => {
dependency: '[email protected]',
installPath: '/path/to/components/component/',
save: false,
silent: true
silent: true,
usePrefix: false
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ describe('cli : domain : handle-dependencies : install-missing-dependencies', ()
dependencies: ['[email protected]', 'underscore@latest'],
installPath: '/path/to/oc-running',
save: false,
silent: true
silent: true,
usePrefix: true
});
});

Expand Down
3 changes: 2 additions & 1 deletion test/unit/cli-domain-init-template-install-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ describe('cli : domain : init-template : install-template', () => {
dependency: 'oc-template-jade-compiler',
installPath: 'path/to/component',
isDev: true,
save: true
save: true,
usePrefix: false
});
});

Expand Down