Skip to content

Instantly share code, notes, and snippets.

@joelrbrandt
Created February 3, 2014 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelrbrandt/8785551 to your computer and use it in GitHub Desktop.
Save joelrbrandt/8785551 to your computer and use it in GitHub Desktop.
Launch new generator-core from old generator-core
(function () {
"use strict";
function startDumping(theGenerator) {
setInterval(function () {
console.log("[UPDATED-LAUNCHER] requesting doc info");
theGenerator.getDocumentInfo().done(
function (info) {
console.log("[UPDATED-LAUNCHER] got doc info: %s", JSON.stringify(info, null, " "));
}, function (err) {
console.log("[UPDATED-LAUNCHER] err getting doc info: %s", err);
});
}, 5000);
}
exports.init = function (oldGenerator, config) {
// Note: Update the require path for updatedGeneratorCore appropriately
var resolve = require("path").resolve,
updatedGeneratorCore = require(resolve(__dirname, "./node_modules/generator-core/lib/generator.js")),
updatedGenerator = updatedGeneratorCore.createGenerator();
console.log("[UPDATED-LAUNCHER] starting updated generator-core");
updatedGenerator.start({
password: "password",
port: 49494,
hostname: "127.0.0.1"
}).done(
function () {
// you're connected!
// use the new updatedGenerator object to do your bidding
console.log("[UPDATED-LAUNCHER] connected, starting dumping loop");
startDumping(updatedGenerator);
},
function (err) {
// something's broken!
// yell at Joel more!
console.error("[UPDATED-LAUNCHER] broken:", err);
}
);
};
}());
{
"name": "updated-launcher",
"version": "0.0.1",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"generator-core": "git+https://github.com/adobe-photoshop/generator-core.git#c8416dea1c7eb305a5461138ea58c93fb457e3fb"
},
"author": "",
"license": "MIT"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment