-
Notifications
You must be signed in to change notification settings - Fork 0
/
wordmove-post-checkout
32 lines (26 loc) · 975 Bytes
/
wordmove-post-checkout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"cd -
/**
* # Wordmove Path Updater
* Post post checkout hook for git that updates the local wordpress path.
* Great work working with teams where the environments are not identical.
*
* ## Installation
* To install save as post-checkout inside .git/hooks
* Make the hook executable with chmod +x .git/hooks/post-checkout
* Make sure you have js-yaml installed globally: npm install -g js-yaml
*
* Connor McKelvey <[email protected]>
*/
var fs = require('fs');
var yaml = require('js-yaml'); //npm install -g js-yaml
try {
var movefile = yaml.safeLoad(fs.readFileSync('Movefile', 'utf8'));
movefile.local.wordpress_path = __dirname.split('/wp-content')[0];
fs.writeFileSync('Movefile', yaml.safeDump(movefile));
console.log('Updated Local Wordpress Path');
} catch(e) {
console.log(e);
console.log('Could Not Update Local Wordpress Path');
process.exit(0);
}