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

Allow publishing from a specific folder using publishPath attribute #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
56 changes: 56 additions & 0 deletions __tests__/plugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,62 @@ describe('@release-it-plugins/workspaces', () => {
expect(readWorkspacePackage('foo').version).toEqual('1.0.1');
});

it('publishes from the publishPath attribute of the package.json', async () => {
setupProject({ packages: ['packages/*'] });

setupWorkspace({ name: 'foo' });
setupWorkspace({ name: 'bar', publishPath: 'dist' });

let plugin = buildPlugin();

await runTasks(plugin);

expect(plugin.operations).toMatchInlineSnapshot(`
Array [
Object {
"command": "npm ping --registry https://registry.npmjs.org",
"operationType": "command",
"options": undefined,
},
Object {
"command": "npm whoami --registry https://registry.npmjs.org",
"operationType": "command",
"options": undefined,
},
Object {
"command": "npm publish ./packages/bar/dist --tag latest",
"operationType": "command",
"options": Object {
"write": false,
},
},
Object {
"command": "npm publish ./packages/foo --tag latest",
"operationType": "command",
"options": Object {
"write": false,
},
},
Object {
"messages": Array [
"🔗 https://www.npmjs.com/package/bar",
],
"operationType": "log",
},
Object {
"messages": Array [
"🔗 https://www.npmjs.com/package/foo",
],
"operationType": "log",
},
]
`);

expect(JSON.parse(dir.readText('package.json')).version).toEqual('1.0.1');
expect(readWorkspacePackage('bar').version).toEqual('1.0.1');
expect(readWorkspacePackage('foo').version).toEqual('1.0.1');
});

it('updates dependencies / devDependencies of packages', async () => {
setupWorkspace({ name: 'derp' });
setupWorkspace({ name: 'qux' });
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ export default class WorkspacesPlugin extends Plugin {
let absolutePath = path.join(root, file);
let pkgInfo = JSONFile.for(absolutePath);

let relativeRoot = path.dirname(file);
let relativeRoot = path.join(path.dirname(file), pkgInfo.pkg.publishPath || '');

return {
root: path.join(root, relativeRoot),
Expand Down