Skip to content

Commit

Permalink
use $HOME/.triple dir for app, fixes #62
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylukasavage committed Oct 19, 2014
1 parent 010680f commit ba4855a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/triple.js
Original file line number Diff line number Diff line change
Expand Up @@ -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|\$)*)\.?$/,
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit ba4855a

Please sign in to comment.