Permalink
Browse files

add "Hint" (without save) command

  • Loading branch information...
1 parent 19e1cc7 commit 079074063eaaf0f457a9571a327329b54e6fa4e6 @stepheneb stepheneb committed Sep 7, 2013
Showing with 42 additions and 1 deletion.
  1. +31 −0 Commands/Hint.tmCommand
  2. +2 −0 Commands/Save and Hint.tmCommand
  3. +9 −1 Support/jshint-tm.js
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>#!/usr/bin/env node
+var env = process.env || process.ENV,
+ jshint = require(env.TM_BUNDLE_SUPPORT + '/jshint-tm');
+ jshint_options = require(env.TM_BUNDLE_SUPPORT + '/jshint_options')();
+
+jshint(jshint_options);</string>
+ <key>input</key>
+ <string>document</string>
+ <key>inputFormat</key>
+ <string>text</string>
+ <key>keyEquivalent</key>
+ <string>^L</string>
+ <key>name</key>
+ <string>Hint</string>
+ <key>outputFormat</key>
+ <string>html</string>
+ <key>outputLocation</key>
+ <string>newWindow</string>
+ <key>scope</key>
+ <string>source.js</string>
+ <key>uuid</key>
+ <string>fc33ecd0-172f-11e3-8ffd-0800200c9a66</string>
+</dict>
+</plist>
@@ -23,5 +23,7 @@ jshint(jshint_options);</string>
<string>source.js</string>
<key>uuid</key>
<string>0048A010-05A0-4A0E-BF97-793A3BA4617D</string>
+ <key>version</key>
+ <integer>2</integer>
</dict>
</plist>
View
@@ -129,7 +129,15 @@ module.exports = function(options) {
if (jshint) {
var file = env.TM_FILEPATH;
- var input = fs.readFileSync(file, 'utf8');
+ var savedFile = fs.readFileSync(file, 'utf8');
+ var currentDocument = fs.readFileSync('/dev/stdin').toString();
+ var input = "";
+
+ if (currentDocument.length > 0) {
+ input = currentDocument;
+ } else {
+ input = savedFile;
+ }
//remove shebang
input = input.replace(/^\#\!.*/, '');

0 comments on commit 0790740

Please sign in to comment.