Comparing version 0.3.5 to 0.3.6
@@ -122,3 +122,3 @@ "use strict"; | ||
function printHelp() { | ||
console.log("\ntsun repl commands\n:type symbol print the type of an identifier\n:doc symbol print the documentation for an identifier\n:clear clear all the code\n:print print code input so far\n:help print this manual\n:paste enter paste mode".blue); | ||
console.log("\ntsun repl commands\n:type symbol print the type of an identifier\n:doc symbol print the documentation for an identifier\n:clear clear all the code\n:print print code input so far\n:help print this manual\n:paste enter paste mode\n:load filename source typescript file in current context".blue); | ||
if (argv.dere) { | ||
@@ -200,2 +200,17 @@ console.log(':baka Who would like some pervert like you, baka~'.blue); | ||
} | ||
function loadFile(filename) { | ||
try { | ||
var filePath = path.resolve(filename); | ||
var fileContents = fs.readFileSync(filePath, 'utf8'); | ||
if (verbose) { | ||
console.log(("loading file: " + filePath).cyan); | ||
console.log(colorize(fileContents)); | ||
console.log('evaluating...'.cyan); | ||
} | ||
startEvaluate(fileContents); | ||
} | ||
catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
function getSource(name) { | ||
@@ -280,2 +295,11 @@ var declarations = service_1.getDeclarations(); | ||
} | ||
if (/^:load/.test(code) && !multilineBuffer) { | ||
var filename = code.split(' ')[1]; | ||
if (!filename) { | ||
console.log(':load: file name expected'.red); | ||
return repl(prompt); | ||
} | ||
loadFile(filename); | ||
return repl(prompt); | ||
} | ||
if (argv.dere && /^:baka/.test(code)) { | ||
@@ -282,0 +306,0 @@ exports.defaultPrompt = 'ξ(゚⊿゚)ξ> '; |
@@ -122,4 +122,4 @@ "use strict"; | ||
function getInitialCommands() { | ||
var codes = getDeclarationFiles().map(function (dir) { return "/// <reference path=\"" + dir + "\" />"; }); | ||
return codes.join('\n'); | ||
return getDeclarationFiles() | ||
.map(function (dir) { return "/// <reference path=\"" + dir + "\" />\n"; }).join(); | ||
} | ||
@@ -126,0 +126,0 @@ // private api hacks |
{ | ||
"name": "tsun", | ||
"preferGlobal": true, | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "TSUN: a repl for TypeScript Upgraded Node", | ||
@@ -6,0 +6,0 @@ "bin": "./bin/tsun", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27029
641