Skip to content

Commit

Permalink
Merge pull request #13 from embroider-build/fix-npm-publish
Browse files Browse the repository at this point in the history
Fix npm publish
  • Loading branch information
mansona authored Nov 23, 2023
2 parents fd954ae + 0206c7f commit 1cf3760
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/interdep.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import glob from 'globby';
import { resolve, join, dirname } from 'path';
import { resolve, relative } from 'path';
import fsExtra from 'fs-extra';
import yaml from 'js-yaml';

Expand All @@ -17,15 +17,15 @@ export function publishedInterPackageDeps(): Map<string, PkgEntry> {
let rootDir = './';
let packages: Map<string, PkgEntry> = new Map();

function loadPackage(dir: string) {
let pkg = readJSONSync(join(dir, 'package.json'));
function loadPackage(packagePath: string) {
let pkg = readJSONSync(packagePath);
if (pkg.private) {
return;
}
pkgJSONS.set(pkg.name, pkg);
packages.set(pkg.name, {
version: pkg.version,
pkgJSONPath: join(dir, 'package.json'),
pkgJSONPath: `./${relative('.', packagePath)}`,
isDependencyOf: new Map(),
isPeerDependencyOf: new Map(),
});
Expand All @@ -34,12 +34,12 @@ export function publishedInterPackageDeps(): Map<string, PkgEntry> {
let pkgJSONS: Map<string, any> = new Map();

if(!existsSync('./pnpm-workspace.yaml')) {
loadPackage('./');
loadPackage('./package.json');
} else {
for (let pattern of (yaml.load(readFileSync('./pnpm-workspace.yaml', 'utf8')) as any)
.packages) {
for (let dir of glob.sync(pattern, { cwd: rootDir, expandDirectories: false, onlyDirectories: true })) {
loadPackage(dirname(resolve(rootDir, dir, 'package.json')))
loadPackage(resolve(rootDir, dir, 'package.json'))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ async function pnpmPublish(solution: Solution, reporter: IssueReporter, dryRun:
}

await execa('pnpm', ['publish', '--access=public'], {
cwd: entry.pkgJSONPath,
cwd: dirname(entry.pkgJSONPath),
stderr: 'inherit',
stdout: 'inherit',
});
} catch (err) {
reporter.reportFailure(`Failed to pnpm publish ${pkgName}`);
reporter.reportFailure(`Failed to pnpm publish ${pkgName} - Error: ${err.message}`);
}
}
}
Expand Down

0 comments on commit 1cf3760

Please sign in to comment.