Skip to content

Commit dec6c8c

Browse files
Upgrade: Report errors when updating dependencies (#16504)
Closes #16391 Like the title suggest this PR adds error reporting when the `npm install` or `npm remove` commands fail. ## Test plan Tested by swapping out the command for `echo "bla"; exit 1` and capturing the output from the integration tests: <img width="792" alt="Screenshot 2025-02-13 at 14 33 02" src="https://github.com/user-attachments/assets/d1288114-106a-4ac6-a54b-d02b74c98f35" /> <img width="761" alt="Screenshot 2025-02-13 at 14 31 05" src="https://github.com/user-attachments/assets/6d5b9427-457f-4e67-9723-4e340da61749" /> Decided not to add a new test for this since it's unlikely we'll do big changes here and the upgrade integration tests are already quite slow.
1 parent 4f18f90 commit dec6c8c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Ensure `--default-outline-width` can be used to change the `outline-width` value of the `outline` utility
2121
- Ensure drop shadow utilities don't inherit unexpectedly ([#16471](https://github.com/tailwindlabs/tailwindcss/pull/16471))
2222
- Export backwards compatible config and plugin types from `tailwindcss/plugin` ([#16505](https://github.com/tailwindlabs/tailwindcss/pull/16505))
23+
- Upgrade: Report errors when updating dependencies ([#16504](https://github.com/tailwindlabs/tailwindcss/pull/16504))
2324

2425
## [4.0.6] - 2025-02-10
2526

packages/@tailwindcss-upgrade/src/utils/packages.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises'
33
import { dirname, resolve } from 'node:path'
44
import { promisify } from 'node:util'
55
import { DefaultMap } from '../../../tailwindcss/src/utils/default-map'
6-
import { warn } from './renderer'
6+
import { error, warn } from './renderer'
77

88
const exec = promisify(execCb)
99

@@ -20,11 +20,28 @@ export function pkg(base: string) {
2020
if (location === 'devDependencies') {
2121
args.push(SAVE_DEV[packageManager] || SAVE_DEV.default)
2222
}
23-
return exec(`${packageManager} add ${args.join(' ')}`, { cwd: base })
23+
24+
let command = `${packageManager} add ${args.join(' ')}`
25+
try {
26+
return await exec(command, { cwd: base })
27+
} catch (e: any) {
28+
error(`An error occurred while running \`${command}\`\n\n${e.stdout}\n${e.stderr}`, {
29+
prefix: '↳ ',
30+
})
31+
throw e
32+
}
2433
},
2534
async remove(packages: string[]) {
2635
let packageManager = await packageManagerForBase.get(base)
27-
return exec(`${packageManager} remove ${packages.join(' ')}`, { cwd: base })
36+
let command = `${packageManager} remove ${packages.join(' ')}`
37+
try {
38+
return await exec(command, { cwd: base })
39+
} catch (e: any) {
40+
error(`An error occurred while running \`${command}\`\n\n${e.stdout}\n${e.stderr}`, {
41+
prefix: '↳ ',
42+
})
43+
throw e
44+
}
2845
},
2946
}
3047
}

0 commit comments

Comments
 (0)