Skip to content
Merged
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
16 changes: 12 additions & 4 deletions .npm/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ if (!existsSync(binPath)) {
process.exit(0);
}

console.log("[cio postinstall] Running: cio skills install");
const child = spawn(binPath, ["skills", "install"], {
stdio: "inherit",
});
const isGlobal = process.env.npm_config_global === "true";
const scopeFlag = isGlobal ? "--global" : "--project";
const spawnOpts = { stdio: "inherit" };

// For project installs, npm runs postinstall with cwd inside node_modules.
// INIT_CWD is the directory where the user ran npm install (the project root).
if (!isGlobal && process.env.INIT_CWD) {
spawnOpts.cwd = process.env.INIT_CWD;
}

console.log(`[cio postinstall] Running: cio skills install ${scopeFlag}`);
const child = spawn(binPath, ["skills", "install", scopeFlag], spawnOpts);

child.on("error", (err) => {
console.log("[cio postinstall] Failed to run cio skills install:", err.message);
Expand Down