Skip to content

Commit

Permalink
feat: allow to specify different docker build context (#59)
Browse files Browse the repository at this point in the history
* fix: avoid deprecated npm bin in tests
  • Loading branch information
pajgo authored Mar 3, 2023
1 parent e72877e commit 852916e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions __tests__/install.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,13 @@ describe('(pnpm) test installing the package', () => {

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

test('returns current node version in module', async () => {
Expand Down
5 changes: 5 additions & 0 deletions bin/cmds/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ exports.builder = (yargs) => (
default: [],
array: true,
})
.option('docker_context', {
alias: 'c',
default: '.',
describe: 'docker build context path',
})
.strict(false)
.help()
);
Expand Down
4 changes: 2 additions & 2 deletions bin/cmds/docker_cmds/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ exports.handler = (argv) => {
`-f ${tmpDockerfile}`,
];

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

// start builder
const command = `${args.join(' ')} .`;
const command = `${args.join(' ')} ${context}`;
echo(command);
const build = exec(command);

Expand Down

0 comments on commit 852916e

Please sign in to comment.