Skip to content

Commit

Permalink
fix: Rm with -f for development-only files and dirs (#60)
Browse files Browse the repository at this point in the history
This patch fixes #58 by force deleting files and directories that would
only exist if development was carried out. Adding -f or force will
suppress any "not found" errors. Examples of development-only include
`node_modules/` and `.eslintcache`.

Closes #58
Ref: #58

Signed-off-by: AlexNg <[email protected]>
  • Loading branch information
caffeine-addictt committed May 29, 2024
1 parent e1c693f commit 4041e6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions dist/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ const { func: main } = (0, io_util_1.withTempDir)('caffeine-addictt-template-',
// ################# //
// Stage 3: Clean up //
// ################# //
// Only add `force: true` for files or directories that
// will only exist if some development task was carried out
// like eslintcache
console.log('Cleaning up...');
// Js
fs_1.default.unlinkSync('package.json');
Expand All @@ -133,16 +136,16 @@ const { func: main } = (0, io_util_1.withTempDir)('caffeine-addictt-template-',
fs_1.default.unlinkSync('babel.config.cjs');
fs_1.default.rmSync('tests', { recursive: true });
// Linting
fs_1.default.unlinkSync('.eslintcache');
fs_1.default.unlinkSync('.eslintignore');
fs_1.default.unlinkSync('.prettierignore');
fs_1.default.unlinkSync('eslint.config.mjs');
fs_1.default.rmSync('.eslintcache', { force: true });
// Syncing
fs_1.default.unlinkSync('.templatesyncignore');
// Git
fs_1.default.unlinkSync('.gitignore');
// Node
fs_1.default.rmSync('node_modules', { recursive: true });
fs_1.default.rmSync('node_modules', { recursive: true, force: true });
// Clean up dist
fs_1.default.unlinkSync(__filename);
fs_1.default.rmSync('dist', { recursive: true });
Expand Down
7 changes: 5 additions & 2 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ const { func: main } = withTempDir(
// ################# //
// Stage 3: Clean up //
// ################# //
// Only add `force: true` for files or directories that
// will only exist if some development task was carried out
// like eslintcache
console.log('Cleaning up...');

// Js
Expand All @@ -182,10 +185,10 @@ const { func: main } = withTempDir(
fs.rmSync('tests', { recursive: true });

// Linting
fs.unlinkSync('.eslintcache');
fs.unlinkSync('.eslintignore');
fs.unlinkSync('.prettierignore');
fs.unlinkSync('eslint.config.mjs');
fs.rmSync('.eslintcache', { force: true });

// Syncing
fs.unlinkSync('.templatesyncignore');
Expand All @@ -194,7 +197,7 @@ const { func: main } = withTempDir(
fs.unlinkSync('.gitignore');

// Node
fs.rmSync('node_modules', { recursive: true });
fs.rmSync('node_modules', { recursive: true, force: true });

// Clean up dist
fs.unlinkSync(__filename);
Expand Down

0 comments on commit 4041e6d

Please sign in to comment.