Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial cmdline yui3 app

  • Loading branch information...
commit c1e69f58578784f4cd42c1578e923590a5f383b0 1 parent 18f9a0a
Dav Glass authored
Showing with 47 additions and 1 deletion.
  1. +43 −0 lib/cmdline.js
  2. +4 −1 package.json
43 lib/cmdline.js
View
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+var YUI = require('yui3').YUI;
+
+var timer = setTimeout(function() {
+ if (html === '') {
+ console.log('No input received..');
+ process.exit(1);
+ }
+}, 2000);
+
+var stdin = process.openStdin(),
+ html = '';
+
+stdin.setEncoding('utf8');
+stdin.on('data', function(data) {
+ html += data;
+});
+stdin.on('end', fireYUI);
+
+
+function fireYUI() {
+ clearTimeout(timer);
+ var args = process.argv.slice(2);
+ //console.log(args);
+ YUI({ logInclude: { cli: true } , debug: true }).use('node', function(Y) {
+ if (html.indexOf('<body') === -1) {
+ //No Body, append to body
+ Y.one('body').append(html);
+ } else if (html.indexOf('<html') > -1) {
+ //This is an HTML doc
+ Y.one('doc').set('innerHTML', html);
+ } else if (html.indexOf('<body') > -1) {
+ //Body without HTML
+ Y.one('body').set('outerHTML', html);
+ }
+ args.forEach(function(v) {
+ Y.log(eval(v));
+ });
+ });
+};
+
+
5 package.json
View
@@ -19,7 +19,10 @@
"lib" : "lib"
},
"main": "./lib/node-yui3",
- "bin" : { "yui3docs" : "./cli.js" },
+ "bin" : {
+ "yui3docs" : "./cli.js",
+ "yui3": "./lib/cmdline.js"
+ },
"dependencies": {
"yui3-core": ">=3.3.0",
"jsdom": ">=0.1.23",
Please sign in to comment.
Something went wrong with that request. Please try again.