Skip to content

Commit

Permalink
fix(publish): Replace forEach loop with for/of (#86)
Browse files Browse the repository at this point in the history
I fall for this async problem every damn time...
  • Loading branch information
lachlancollins committed May 13, 2024
1 parent 1276c85 commit d44d223
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/publish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,28 +419,28 @@ export const publish = async (options) => {

console.info()
console.info('Clear package scripts...')
changedPackages.forEach(async (pkg) => {
for (const pkg of changedPackages) {
await updatePackageJson(
path.resolve(rootDir, pkg.packageDir, 'package.json'),
(config) => {
config.scripts = {}
},
)
})
}

console.info()
console.info(`Publishing all packages to npm with tag "${npmTag}"`)

// Publish each package
changedPackages.forEach((pkg) => {
for (const pkg of changedPackages) {
const packageDir = path.join(rootDir, pkg.packageDir)

const cmd = `cd ${packageDir} && pnpm publish --tag ${npmTag} --access=public --no-git-checks`
console.info(` Publishing ${pkg.name}@${version} to npm...`)
execSync(cmd, {
stdio: [process.stdin, process.stdout, process.stderr],
})
})
}

console.info()
console.info('Pushing changes...')
Expand Down

0 comments on commit d44d223

Please sign in to comment.