Skip to content

Commit

Permalink
'pm seteditor' can be used as 'pm seteditor [commandToOpenEditor]'
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhdaware committed Sep 7, 2019
1 parent ef24b2d commit 212b0df
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 53 deletions.
5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
tests
tests
mocharc.json
images/terminal.gif
build
2 changes: 1 addition & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ program
.action(action.removeProject);

program
.command('seteditor')
.command('seteditor [commandToOpen]')
.description("Set text editor to use")
.action(action.setEditor);

Expand Down
16 changes: 0 additions & 16 deletions build/prepublish.js

This file was deleted.

67 changes: 37 additions & 30 deletions lib/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,44 @@ async function openProject(projectName){

}

async function setEditor(){
const editors = [
{
type: 'list',
message: 'Select text editor',
name: 'selectedEditor',
choices: [
{
name:'VSCode',
value:'code'
},
{
name:'Sublime',
value:'subl'
},
{
name:'Atom',
value:'atom'
},
{
name:'Vim',
value:'vim'
}
]
}
];

console.log(); // Just wanted to line break; Sorry god of good practices ;_;
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`)
({selectedEditor:settings.commandToOpen} = await inquirer.prompt(editors));
async function setEditor(command){
let commandToOpen;
if(!command){
const editors = [
{
type: 'list',
message: 'Select text editor',
name: 'selectedEditor',
choices: [
{
name:'VSCode',
value:'code'
},
{
name:'Sublime',
value:'subl'
},
{
name:'Atom',
value:'atom'
},
{
name:'Vim',
value:'vim'
}
]
}
];

console.log(); // Just wanted to line break; Sorry god of good practices ;_;
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`)
({selectedEditor:commandToOpen} = await inquirer.prompt(editors));
}else{
commandToOpen = command;
}

settings.commandToOpen = commandToOpen;

writeSettings(settings,'seteditor',"Text Editor Selected");
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "projectman",
"version": "1.0.1",
"version": "1.1.0-rc.2",
"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.",
"main": "bin/index.js",
"bin": {
Expand All @@ -9,9 +9,7 @@
},
"preferGlobal": true,
"scripts": {
"test": "mocha --recursive \"./tests/*.js\"",
"prepublishOnly": "node build/prepublish.js",
"restoreSettings": "npm run prepublishOnly"
"test": "mocha --recursive \"./tests/*.js\""
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 212b0df

Please sign in to comment.