Permalink
Browse files

Fixed YUI being out of scope in a few places

  • Loading branch information...
1 parent 6ea9f72 commit c3e07f3e19e26b1c33e5cb1d1b29a0a67115dc4f @davglass committed Apr 7, 2011
Showing with 14 additions and 6 deletions.
  1. +3 −2 bin/yui-repl.js
  2. +11 −4 lib/repl.js
View
@@ -22,6 +22,7 @@ cli.main(function() {
var opts = this.options;
var Y = require('yui3');
+ var YUI = Y.YUI;
if (opts.silent == 'on') {
Y = Y.silent();
}
@@ -30,10 +31,10 @@ cli.main(function() {
var start = function() {
if (opts.get) {
util.print('Fetching script:'.magenta + opts.get.yellow);
- var r = yrepl.startPrompt(Y);
+ var r = yrepl.startPrompt(Y, YUI);
r.commands['.get'].action.call(r, opts.get);
} else {
- yrepl.startPrompt(Y);
+ yrepl.startPrompt(Y, YUI);
}
}
View
@@ -10,7 +10,7 @@ replServer.REPLServer.prototype.displayPrompt = function() {
require('colors');
-exports.startPrompt = function(Y) {
+exports.startPrompt = function(Y, YUI) {
var prompt = 'YUI@' + Y.version + '> ';
len = prompt.length;
@@ -23,11 +23,15 @@ exports.startPrompt = function(Y) {
var ctx = repl.context;
ctx.Y = Y;
+ ctx.YUI = YUI;
var clear = function(write) {
this.outputStream.write('Resetting Y to the default state'.magenta);
this.bufferedCommand = '';
- this.context.Y = require('yui3').silent().useSync('yui-base');
+ var yui = require('yui3');
+ var Y = yui.silent().useSync('yui-base');
+ this.context.Y = Y;
+ this.context.YUI = yui.YUI;
this.outputStream.write(' [done]\n'.white);
if (write !== false) {
this.displayPrompt();
@@ -224,7 +228,8 @@ exports.startPrompt = function(Y) {
help: 'Make an YQL request with the passed SQL statement',
action: function(sql) {
var self = this,
- Y = this.context.Y;
+ Y = this.context.Y;
+
self.outputStream.write('Making YQL Request: '.magenta + sql.yellow);
Y.use('yql', function() {
Y.YQL(sql, function(r) {
@@ -247,7 +252,9 @@ exports.startPrompt = function(Y) {
repl.defineCommand('get', {
help: 'Get a remote/local script and eval it into this context',
action: function(url) {
- var self = this;
+ var self = this,
+ Y = this.context.Y;
+
self.outputStream.write('Fetching Script: '.magenta + url.yellow);
Y.Get.script(url, {
onSuccess: function() {

0 comments on commit c3e07f3

Please sign in to comment.