Skip to content

Commit 212b0df

Browse files
committed
'pm seteditor' can be used as 'pm seteditor [commandToOpenEditor]'
1 parent ef24b2d commit 212b0df

File tree

6 files changed

+45
-53
lines changed

6 files changed

+45
-53
lines changed

.npmignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
tests
1+
tests
2+
mocharc.json
3+
images/terminal.gif
4+
build

bin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ program
2323
.action(action.removeProject);
2424

2525
program
26-
.command('seteditor')
26+
.command('seteditor [commandToOpen]')
2727
.description("Set text editor to use")
2828
.action(action.setEditor);
2929

build/prepublish.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

lib/action.js

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,37 +111,44 @@ async function openProject(projectName){
111111

112112
}
113113

114-
async function setEditor(){
115-
const editors = [
116-
{
117-
type: 'list',
118-
message: 'Select text editor',
119-
name: 'selectedEditor',
120-
choices: [
121-
{
122-
name:'VSCode',
123-
value:'code'
124-
},
125-
{
126-
name:'Sublime',
127-
value:'subl'
128-
},
129-
{
130-
name:'Atom',
131-
value:'atom'
132-
},
133-
{
134-
name:'Vim',
135-
value:'vim'
136-
}
137-
]
138-
}
139-
];
140-
141-
console.log(); // Just wanted to line break; Sorry god of good practices ;_;
142-
console.warn(`If the TextEditor/IDE you are looking for is not listed here, Run ${chalk.yellow('pm edit')} and set value of ${chalk.yellow('commandToOpen')} to the command of your text editor ${chalk.grey('(e.g "code" for VSCode)')}\n`)
143-
({selectedEditor:settings.commandToOpen} = await inquirer.prompt(editors));
114+
async function setEditor(command){
115+
let commandToOpen;
116+
if(!command){
117+
const editors = [
118+
{
119+
type: 'list',
120+
message: 'Select text editor',
121+
name: 'selectedEditor',
122+
choices: [
123+
{
124+
name:'VSCode',
125+
value:'code'
126+
},
127+
{
128+
name:'Sublime',
129+
value:'subl'
130+
},
131+
{
132+
name:'Atom',
133+
value:'atom'
134+
},
135+
{
136+
name:'Vim',
137+
value:'vim'
138+
}
139+
]
140+
}
141+
];
142+
143+
console.log(); // Just wanted to line break; Sorry god of good practices ;_;
144+
console.warn(`If the TextEditor/IDE you are looking for is not listed here, Run ${chalk.yellow('pm seteditor [commandToOpenEditor]')} \n'commandToOpenEditor' is the command you can type in terminal to open project E.g for Webstorm it is 'wstorm' for VSCode it is 'code'\n`)
145+
({selectedEditor:commandToOpen} = await inquirer.prompt(editors));
146+
}else{
147+
commandToOpen = command;
148+
}
144149

150+
settings.commandToOpen = commandToOpen;
151+
145152
writeSettings(settings,'seteditor',"Text Editor Selected");
146153
}
147154

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "projectman",
3-
"version": "1.0.1",
3+
"version": "1.1.0-rc.2",
44
"description": "Hate opening folders? Select and open your projects in your favourite editor straight from your command line without 'CD'ing into the deeply nested folders.",
55
"main": "bin/index.js",
66
"bin": {
@@ -9,9 +9,7 @@
99
},
1010
"preferGlobal": true,
1111
"scripts": {
12-
"test": "mocha --recursive \"./tests/*.js\"",
13-
"prepublishOnly": "node build/prepublish.js",
14-
"restoreSettings": "npm run prepublishOnly"
12+
"test": "mocha --recursive \"./tests/*.js\""
1513
},
1614
"repository": {
1715
"type": "git",

0 commit comments

Comments
 (0)