Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from Gigitsu/master
Browse files Browse the repository at this point in the history
Added command to run last npm script
  • Loading branch information
fknop committed May 28, 2016
2 parents 4708521 + 7246ad4 commit d9a246d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"onCommand:npm-script.installPackage",
"onCommand:npm-script.installPackageDev",
"onCommand:npm-script.runScript",
"onCommand:npm-script.reRunScript",
"onCommand:npm-script.init",
"onCommand:npm-script.uninstallPackage",
"onCommand:npm-script.uninstallPackageDev",
Expand Down Expand Up @@ -52,6 +53,11 @@
"title": "Run npm script",
"category": "npm"
},
{
"command": "npm-script.reRunScript",
"title": "Run last npm script",
"category": "npm"
},
{
"command": "npm-script.init",
"title": "Initialize npm package",
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { outputChannel } from './output';
import * as Messages from './messages';
import { runCommand } from './run-command';

import npmRunScript from './run';
import npmInit from './init';
import { npmInstallPackage, npmInstallPackageDev, npmInstallSavedPackages } from './install';
import { npmUninstallPackage, npmUninstallPackageDev } from './uninstall';
import {npmRunScript, npmReRunScript} from './run';
import { npmPublish } from './publish';
import { npmDeprecate } from './deprecate';
import { npmRawCommand } from './raw';
Expand All @@ -20,6 +20,7 @@ export const activate = function (context: ExtensionContext) {
Commands.registerCommand('npm-script.installPackage', npmInstallPackage),
Commands.registerCommand('npm-script.installPackageDev', npmInstallPackageDev),
Commands.registerCommand('npm-script.runScript', npmRunScript),
Commands.registerCommand('npm-script.reRunScript', npmReRunScript),
Commands.registerCommand('npm-script.init', npmInit),
Commands.registerCommand('npm-script.uninstallPackage', npmUninstallPackage),
Commands.registerCommand('npm-script.uninstallPackageDev', npmUninstallPackageDev),
Expand Down
4 changes: 4 additions & 0 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function noProjectOpenError () {
Window.showErrorMessage('No project open');
};

export function noLastScript() {

Window.showErrorMessage('No script executed yet')
}

export function noScriptsInfo () {

Expand Down
13 changes: 11 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { workspace as Workspace,
import * as Messages from './messages';
import { runCommand } from './run-command';

export default function () {
var lastScript:QuickPickItem;

export function npmRunScript () {

const scripts = readScripts();
if (!scripts) {
Expand All @@ -20,11 +22,18 @@ export default function () {
});

Window.showQuickPick(items).then((value) => {

lastScript = value;
runCommand(['run', value.label]);
});
};

export function npmReRunScript() {
if(lastScript)
runCommand(['run', lastScript.label]);
else
Messages.noLastScript();
}

const readScripts = function () {

const filename = Path.join(Workspace.rootPath, 'package.json');
Expand Down

0 comments on commit d9a246d

Please sign in to comment.