Skip to content

Commit 7e0b74e

Browse files
committed
resolve path issues
1 parent 9a4cd6c commit 7e0b74e

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const ncp = require('ncp').ncp;
44
const changeCase = require('change-case');
55
const shell = require('shelljs');
66
const replaceInFiles = require('replace-in-files');
7-
87
ncp.limit = 16;
98

109
let destinationPath = "";
@@ -44,9 +43,10 @@ const locationSelector = async (path)=>{
4443
//prompt user to select tech stack and save it to a config file
4544
const stackTypeSelector = async (path)=> {
4645
path= path ? path:__dirname+"/developer-templates";
47-
let techStack = ""
46+
console.log("stackTypeSelector",path);
47+
console.log(__dirname)
4848
try {
49-
return JSON.parse(fs.readFileSync("developer-templates/input.json")).techStack;
49+
return JSON.parse(fs.readFileSync(__dirname+"developer-templates/config.json")).techStack;
5050
}catch (e) {
5151
let folderList = getFolderList(path);
5252
const response = await prompts({
@@ -55,7 +55,7 @@ const stackTypeSelector = async (path)=> {
5555
message: 'Select your Project stack',
5656
choices: folderList
5757
});
58-
fs.writeFile ("developer-templates/input.json", JSON.stringify(response), function(err) {
58+
fs.writeFile ("developer-templates/config.json", JSON.stringify(response), function(err) {
5959
if (err) throw err;
6060
console.log('Response was saved to /developer-templates/config.json. Delete this file if you want to change it later.');
6161
}
@@ -69,6 +69,7 @@ const templateSelector = async (path)=> {
6969
const techStack = await stackTypeSelector();
7070
console.log ("Available templates for " +techStack);
7171
path = path ? path:__dirname+"/developer-templates/"+techStack;
72+
console.log("templateSelector",path)
7273
let folderList = getFolderList(path);
7374
const response = await prompts({
7475
type: 'autocomplete',

init.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const ncp = require('ncp').ncp;
2+
const npmAddScript = require('npm-add-script')
3+
4+
ncp("node_modules/react-react-native-component-node-module-templates/developer-templates","developer-templates")
5+
npmAddScript({key: "gen" , value: "node node_modules/react-react-native-component-node-module-templates/index.js" , force: true})

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"shelljs": "^0.8.4"
1616
},
1717
"scripts": {
18-
"postinstall": "node index.js"
18+
"gen": "node index.js",
19+
"init": "node init.js"
1920
}
2021
}

0 commit comments

Comments
 (0)