diff --git a/.npmignore b/.npmignore index 3598c30..ca746b9 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,4 @@ -tests \ No newline at end of file +tests +mocharc.json +images/terminal.gif +build \ No newline at end of file diff --git a/bin/index.js b/bin/index.js index 89939d1..4cae316 100755 --- a/bin/index.js +++ b/bin/index.js @@ -23,7 +23,7 @@ program .action(action.removeProject); program - .command('seteditor') + .command('seteditor [commandToOpen]') .description("Set text editor to use") .action(action.setEditor); diff --git a/build/prepublish.js b/build/prepublish.js deleted file mode 100644 index 4642983..0000000 --- a/build/prepublish.js +++ /dev/null @@ -1,16 +0,0 @@ -const fs = require('fs'); - - -function setDefaultSettings(){ - const data = { - "commandToOpen": "code", - "projects": [] - } - - fs.writeFileSync('./lib/settings.json',JSON.stringify(data,null,4),'utf8'); - return data; -} - - - -setDefaultSettings(); \ No newline at end of file diff --git a/lib/action.js b/lib/action.js index e31fccd..7341e2b 100644 --- a/lib/action.js +++ b/lib/action.js @@ -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"); } diff --git a/package-lock.json b/package-lock.json index e3dd6f6..eca0ea5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "projectman", - "version": "1.0.0", + "version": "1.1.0-rc.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3174e8d..5db94be 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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",