Created
June 12, 2011 04:02
-
-
Save anonymous/1021238 to your computer and use it in GitHub Desktop.
Pasted form Komodo IDE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sanitize_name = function(s) { | |
return s.replace(/[\s\.]*/g, '').toLowerCase(); | |
} | |
var os = Components.classes['@activestate.com/koOs;1']. | |
getService(Components.interfaces.koIOs); | |
var project_root = ko.filepicker.getFolder(os.getcwd(), "Choose a directory to create your new project in."); | |
// var project_root = '/Users/jeff/code/moz/jetpack/tmp/two'; | |
var name = ko.dialogs.prompt('Addon name', 'What do you want to call your new extension?'); | |
var safe_name = sanitize_name(name); | |
var dir = os.path.join(project_root, safe_name); | |
function jetpack_init(base_dir, safe_name) { | |
try { | |
var dir = os.path.join(project_root, safe_name); | |
os.mkdir(dir); | |
// should be in extension prefs | |
var cmd = '/Users/jeff/code/moz/jetpack/addon-sdk/bin/cfx ' | |
+ '-b /Applications/Coms/Firefox4.app ' | |
+ 'init'; | |
cmd += " {'cwd': u'"+ dir +"'}"; // necessary? | |
ko.run.runEncodedCommand(window, cmd, function() { | |
create_project(dir, safe_name); | |
}); | |
} | |
catch(e) { | |
ko.eggs.writeLine(e); | |
} | |
} | |
function create_project(dir, name) { | |
var projectName = name + '.komodoproject'; | |
var path_list = [dir, projectName]; | |
var url = ko.uriparse.localPathToURI(os.path.joinlist(path_list.length, path_list)); | |
var project = Components.classes["@activestate.com/koProject;1"] | |
.createInstance(Components.interfaces.koIProject); | |
project.create(); | |
project.url = url; | |
project.save(); | |
ko.projects.open(url); | |
} | |
jetpack_init(project_root, safe_name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment