Skip to content
Open
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
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function spawnNpmWithOutput(args, options) {
});
}

async function packWithNpm({ sourceDir, targetDir, verbose }) {
const output = (await spawnNpmWithOutput(['pack', sourceDir], {
async function packWithNpm({ packageSpec, targetDir, verbose }) {
const output = (await spawnNpmWithOutput(['pack', packageSpec], {
cwd: targetDir,
verbose
})).trim().split(/\n/);
Expand All @@ -60,7 +60,7 @@ async function packWithNpm({ sourceDir, targetDir, verbose }) {
}
}

async function publish({tag, branch, version, push, packOptions}, pack = packWithNpm) {
async function publish({tag, branch, version, push, packageSpec, packOptions}, pack = packWithNpm) {
if (!tag) {
tag = `v${version}`;
}
Expand All @@ -86,7 +86,7 @@ async function publish({tag, branch, version, push, packOptions}, pack = packWit
}

await pack(Object.assign({
sourceDir: process.cwd(),
packageSpec: packageSpec,
targetDir: tmpDir,
}, packOptions));

Expand Down
15 changes: 14 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const argv = yargs
.describe('branch', "Branch name to append this new release to - none by default")
.describe('push', 'Push update to the git remote (pass --no-push to disable)')
.describe('force', 'Override any existing tag on the remote as well as locally (git tag -f, git push -f)')
.parserConfiguration({ 'populate--': true })
.describe('--', 'All arguments after -- are passed to npm pack command')
.boolean('push')
.boolean('force')
.default('push', 'true')
Expand All @@ -21,6 +23,16 @@ const argv = yargs
const path = require('path');
const packageJson = require(path.join(process.cwd(), '/package.json'));

// packageSpec is the first non-option token after `--`.
// Remaining forwarded tokens are forwarded.
const forwarded = yargs(argv['--'] || [])
.default('verbose', 'true')
.wrap(yargs.terminalWidth())
.argv;

const packageSpec = forwarded._.length > 0 ? forwarded._ : process.cwd();
console.log('Using packageSpec:', packageSpec);

publish({
tag: argv.tag,
branch: argv.branch,
Expand All @@ -30,8 +42,9 @@ publish({
remote: argv.remote,
force: argv.force,
},
packageSpec,
packOptions: {
verbose: true
...forwarded
}
}).catch(err => {
if (err.cmd) {
Expand Down