Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab8ea66

Browse filesBrowse files
authored
fix(publish): ignore unnecessary files when publishing to npm (#3024)
1 parent 7aaa702 commit ab8ea66
Copy full SHA for ab8ea66

1 file changed

+10Lines changed: 10 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tools/publish.js‎

Copy file name to clipboardExpand all lines: tools/publish.js
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,22 @@ const publisher = new Listr([
6060
return {
6161
title: `Publishing: ${chalk.cyan(`${name}@${version}`)} (beta=${isBeta ? chalk.green('true') : chalk.red('false')})`,
6262
task: async () => {
63+
const npmIgnorePath = path.join(dir, '.npmignore');
64+
let writtenNpmIgnore = false;
65+
6366
try {
67+
await fs.promises.writeFile(npmIgnorePath, ['*.ts', '!*.d.ts', '*.tsbuildinfo', 'tsconfig.json', '*.map', '/test'].join('\n'));
68+
writtenNpmIgnore = true;
69+
6470
await spawn('npm', ['publish', '--access=public', ...(isBeta ? ['--tag=beta'] : []), `--otp=${ctx.otp}`], {
6571
cwd: dir,
6672
});
6773
} catch (err) {
6874
throw new Error(`Failed to publish ${chalk.cyan(`${name}@${version}`)} \n${err.stderr.toString()}`);
75+
} finally {
76+
if (writtenNpmIgnore) {
77+
await fs.promises.rm(npmIgnorePath);
78+
}
6979
}
7080
},
7181
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.