Skip to content

Commit 852916e

Browse files
authored
feat: allow to specify different docker build context (#59)
* fix: avoid deprecated npm bin in tests
1 parent e72877e commit 852916e

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

__tests__/install.spec.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,13 @@ describe('(pnpm) test installing the package', () => {
289289

290290
describe('installs globally', () => {
291291
test('is able to install package globally', async () => {
292-
const { stdout, stderr } = await execa('npm', ['bin', '--location=global'], { buffer: true });
293-
await execa('pnpm', ['config', 'set', `global-bin-dir=${stdout}`]);
294-
await execa('pnpm', ['-g', 'add', tarball]);
292+
const { stdout, stderr } = await execa('npm', ['prefix', '--location=global'], { buffer: true });
293+
const globalBinDir = `${stdout}/bin`;
294+
await execa('pnpm', ['-g', 'add', tarball], {
295+
env: {
296+
PNPM_HOME: globalBinDir,
297+
},
298+
});
295299
}, 240000);
296300

297301
test('returns current node version in module', async () => {

bin/cmds/docker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ exports.builder = (yargs) => (
3434
default: [],
3535
array: true,
3636
})
37+
.option('docker_context', {
38+
alias: 'c',
39+
default: '.',
40+
describe: 'docker build context path',
41+
})
3742
.strict(false)
3843
.help()
3944
);

bin/cmds/docker_cmds/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ exports.handler = (argv) => {
4141
`-f ${tmpDockerfile}`,
4242
];
4343

44-
const { docker_build_args: dba } = argv;
44+
const { docker_build_args: dba, docker_context: context } = argv;
4545
if (dba && typeof dba === 'object') {
4646
for (const [prop, value] of Object.entries(dba)) {
4747
args.push(`--build-arg ${prop}=${value}`);
4848
}
4949
}
5050

5151
// start builder
52-
const command = `${args.join(' ')} .`;
52+
const command = `${args.join(' ')} ${context}`;
5353
echo(command);
5454
const build = exec(command);
5555

0 commit comments

Comments
 (0)