File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const path = require ( "path" ) ;
3+
4+ module . exports = async function ( repos , args ) {
5+ try {
6+ if ( args . length < 2 ) {
7+ console . error ( "Please provide both source and destination paths." ) ;
8+ return ;
9+ }
10+
11+ const srcPath = path . resolve ( process . cwd ( ) , args [ 0 ] ) ;
12+ const destPath = path . resolve ( process . cwd ( ) , args [ 1 ] ) ;
13+
14+ if ( ! fs . existsSync ( srcPath ) ) {
15+ console . error ( `Source path does not exist: ${ srcPath } ` ) ;
16+ return ;
17+ }
18+
19+ try {
20+ // Always remove the destination entry if it exists
21+ if ( fs . existsSync ( destPath ) ) {
22+ await fs . promises . rm ( destPath , { recursive : true , force : true } ) ;
23+ }
24+
25+ // Create a symlink for the directory
26+ await fs . promises . symlink ( srcPath , destPath , "dir" ) ;
27+ console . log ( `Directory symlink created: ${ srcPath } -> ${ destPath } ` ) ;
28+ } catch ( err ) {
29+ console . error ( `Failed to create symlink for ${ srcPath } :` , err ) ;
30+ }
31+
32+ console . log ( "Symlinking complete." ) ;
33+ } catch ( err ) {
34+ console . error ( "Error during symlinking process:" , err ) ;
35+ }
36+ } ;
You can’t perform that action at this time.
0 commit comments