Skip to content

Commit

Permalink
Merge pull request #1262 from opencomponents/optional-prefix
Browse files Browse the repository at this point in the history
[BUGFIX] Add back --prefix when installing dependencies
  • Loading branch information
ricardo-devis-agullo authored Oct 21, 2021
2 parents 348035a + 960d990 commit 27d4f3e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
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

0 comments on commit 27d4f3e

Please sign in to comment.