Created
September 20, 2019 16:42
-
-
Save nullvariable/9b8d2e20e12610dc87d147d276828555 to your computer and use it in GitHub Desktop.
Create symlinks with Quicksilver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api_version: 1 | |
workflows: | |
sync_code: | |
after: | |
- type: webphp | |
description: Create symlinks | |
script: private/symlinks.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$root = dirname( __DIR__ ); // may need to adjust this if using a nested webroot | |
$paths = [ | |
[ | |
'target' => $root . '/path/to/real/file/dir', | |
'link' => $root . '/desired/path', | |
], | |
[ | |
'target' => $root . '/another/real/file.txt', | |
'link' => $root . '/another/desired/path.txt', | |
], | |
]; | |
foreach ( $paths as $config ) { | |
if ( !file_exists($config['link']) ) { | |
if ( file_exists($config['target']) ) { | |
symlink( $config['target'], $config['link'] ); | |
echo "\nCreated symlink " . $config['link']; | |
} else { | |
echo "\nSymlink target not found: " . $config['target']; | |
} | |
} else { | |
echo "\nsymlink found " . $config['link']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment