From ba4855a7f22cc74d10051d2e4b9f4e7ebd31aeb1 Mon Sep 17 00:00:00 2001 From: Tony Lukasavage Date: Sun, 19 Oct 2014 16:18:18 -0400 Subject: [PATCH] use $HOME/.triple dir for app, fixes #62 --- lib/triple.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/triple.js b/lib/triple.js index b9a6cc9..a1509ac 100644 --- a/lib/triple.js +++ b/lib/triple.js @@ -13,10 +13,8 @@ var _ = require('lodash'), titanium = require('./titanium'), util = require('./util'); -var DEFAULTS = { - PROJECT: '_tmp', - ID: 'triple.tmpapp' -}; +var TRIPLE_DIR = path.resolve(process.env.HOME || process.env.USERPROFILE || '.', '.triple'); +var TRIPLE_APP = path.join(TRIPLE_DIR, 'app'); var requireRE = /\brequire\s*\(['"](([\w\.\/-]+\/)?([\w\.\/-]*))/, simpleExpressionRE = /(([a-zA-Z_$](?:\w|\$)*)\.)*([a-zA-Z_$](?:\w|\$)*)\.?$/, @@ -30,11 +28,16 @@ module.exports = function(opts, callback) { opts = {}; } + // setup logging if (opts.verbose) { titanium.verbose = true; logger.verbose = true; } + // create .triple folder + fs.ensureDirSync(TRIPLE_DIR); + + // create readline interface var rl = readline.createInterface({ input: process.stdin, output: process.stdout, @@ -93,12 +96,13 @@ module.exports = function(opts, callback) { // create the repl project function(cb) { - if (!fs.existsSync(DEFAULTS.PROJECT)) { + if (!fs.existsSync(TRIPLE_APP)) { logger.log('[creating app]'); var interval = spinner(); var createOpts = _.defaults(opts.create || {}, { - name: DEFAULTS.PROJECT, - id: DEFAULTS.ID, + name: 'app', + id: 'triple.tmpapp', + workspaceDir: TRIPLE_DIR, logLevel: 'error' }); titanium.create(createOpts, function(err, results) { @@ -115,7 +119,7 @@ module.exports = function(opts, callback) { // prep app function(cb) { - var resources = path.join(DEFAULTS.PROJECT, 'Resources'), + var resources = path.join(TRIPLE_APP, 'Resources'), app = path.join(__dirname, '..', 'app'); // copy in all app files @@ -128,7 +132,7 @@ module.exports = function(opts, callback) { // load native modules into tiapp.xml if(opts.module) { - var tiapp = tiappXml.load(path.resolve(DEFAULTS.PROJECT, 'tiapp.xml')); + var tiapp = tiappXml.load(path.resolve(TRIPLE_APP, 'tiapp.xml')); opts.module.forEach(function(id) { logger.log('[Injecting module: %s]', id); tiapp.setModule(id); @@ -152,7 +156,7 @@ module.exports = function(opts, callback) { logger.log('[launching app]'); var interval = spinner(); var buildOpts = _.defaults(opts.build || {}, { - projectDir: DEFAULTS.PROJECT, + projectDir: TRIPLE_APP, platform: 'ios', noSimFocus: true, server: server