@@ -1202,26 +1202,32 @@ export function readJsonSync(
12021202
12031203/**
12041204 * Safely delete a file or directory asynchronously with built-in protections.
1205- * Uses `del` for safer deletion that prevents removing cwd and above by default.
1206- * Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories.
1205+ *
1206+ * Uses `del` for safer deletion with these safety features:
1207+ * - By default, prevents deleting the current working directory (cwd) and above
1208+ * - Allows deleting within cwd (descendant paths) without force option
1209+ * - Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories
1210+ * - Protects against accidental deletion of parent directories via `../` paths
12071211 *
12081212 * @param filepath - Path or array of paths to delete (supports glob patterns)
12091213 * @param options - Deletion options including force, retries, and recursion
1214+ * @param options.force - Set to true to allow deleting cwd and above (use with caution)
12101215 * @throws {Error } When attempting to delete protected paths without force option
12111216 *
12121217 * @example
12131218 * ```ts
1214- * // Delete a single file
1215- * await safeDelete('./temp-file.txt')
1216- *
1217- * // Delete a directory recursively
1218- * await safeDelete('./build', { recursive: true })
1219+ * // Delete files within cwd (safe by default)
1220+ * await safeDelete('./build')
1221+ * await safeDelete('./dist')
12191222 *
1220- * // Delete multiple paths
1221- * await safeDelete(['./dist ', './coverage '])
1223+ * // Delete with glob patterns
1224+ * await safeDelete(['./temp/** ', '!./temp/keep.txt '])
12221225 *
12231226 * // Delete with custom retry settings
12241227 * await safeDelete('./flaky-dir', { maxRetries: 5, retryDelay: 500 })
1228+ *
1229+ * // Force delete cwd or above (requires explicit force: true)
1230+ * await safeDelete('../parent-dir', { force: true })
12251231 * ```
12261232 */
12271233export async function safeDelete (
@@ -1277,26 +1283,32 @@ export async function safeDelete(
12771283
12781284/**
12791285 * Safely delete a file or directory synchronously with built-in protections.
1280- * Uses `del` for safer deletion that prevents removing cwd and above by default.
1281- * Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories.
1286+ *
1287+ * Uses `del` for safer deletion with these safety features:
1288+ * - By default, prevents deleting the current working directory (cwd) and above
1289+ * - Allows deleting within cwd (descendant paths) without force option
1290+ * - Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories
1291+ * - Protects against accidental deletion of parent directories via `../` paths
12821292 *
12831293 * @param filepath - Path or array of paths to delete (supports glob patterns)
12841294 * @param options - Deletion options including force, retries, and recursion
1295+ * @param options.force - Set to true to allow deleting cwd and above (use with caution)
12851296 * @throws {Error } When attempting to delete protected paths without force option
12861297 *
12871298 * @example
12881299 * ```ts
1289- * // Delete a single file
1290- * safeDeleteSync('./temp-file.txt')
1300+ * // Delete files within cwd (safe by default)
1301+ * safeDeleteSync('./build')
1302+ * safeDeleteSync('./dist')
12911303 *
1292- * // Delete a directory recursively
1293- * safeDeleteSync('./build ', { recursive: true } )
1304+ * // Delete with glob patterns
1305+ * safeDeleteSync([ './temp/** ', '!./temp/keep.txt'] )
12941306 *
1295- * // Delete multiple paths with globs
1296- * safeDeleteSync(['./dist/** ', './coverage/** '])
1307+ * // Delete multiple paths
1308+ * safeDeleteSync(['./coverage ', './reports '])
12971309 *
1298- * // Force delete a protected path (use with caution )
1299- * safeDeleteSync('./important ', { force: true })
1310+ * // Force delete cwd or above (requires explicit force: true )
1311+ * safeDeleteSync('../parent-dir ', { force: true })
13001312 * ```
13011313 */
13021314export function safeDeleteSync (
0 commit comments