-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create postinstall script to set symlink
this will create symlink 2 levels above the node location. it will create cz-config file in your porject root and the symlink inside this node package closes #1
- Loading branch information
1 parent
54480ca
commit f5b8b14
Showing
4 changed files
with
66 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
var path = require('path'); | ||
var fs = require('fs'); | ||
|
||
var SYM_LINK_LOCATION = './cz-config'; | ||
var CZ_CONFIG_NAME = '.cz-config'; | ||
var CZ_CONFIG_EXAMPLE_LOCATION = './cz-config-EXAMPLE.js'; | ||
|
||
|
||
|
||
fs.stat(path.resolve('./../../' + CZ_CONFIG_NAME), function(err, stats){ | ||
if (err) { | ||
console.info('>>> config file doesn\'t exist. I will create one for you.'); | ||
fs.writeFileSync(path.resolve('./../../' + CZ_CONFIG_NAME), fs.readFileSync(path.resolve(CZ_CONFIG_EXAMPLE_LOCATION))); | ||
} else { | ||
console.info('>>> file ' + CZ_CONFIG_NAME + ' already exist in your project root. We will NOT override it.'); | ||
} | ||
|
||
}); | ||
|
||
//first delete any existing symbolic link. | ||
fs.unlink(SYM_LINK_LOCATION, function(err){ | ||
|
||
// create or re-create symlink to file located 2 dirs up. | ||
console.info('>>> cz-customizable is about to create this symlink "' + __dirname + '/.cz-config" to point to your project root directory, 2 levels up.'); | ||
fs.symlinkSync(path.resolve('./../../' + CZ_CONFIG_NAME), path.resolve(SYM_LINK_LOCATION), 'file') | ||
}); |
This file contains 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