From 01f059d156d35c5d0a1bdf016c1bc5f5d91bb3de Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 12 Feb 2015 13:23:29 -0800 Subject: [PATCH] Allow atom home to be passed in --- src/compile-cache.coffee | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/compile-cache.coffee b/src/compile-cache.coffee index d5e9f0ccf..3eeac000a 100644 --- a/src/compile-cache.coffee +++ b/src/compile-cache.coffee @@ -1,22 +1,21 @@ path = require 'path' - CSON = require 'season' CoffeeCache = require 'coffee-cash' to5 = require './6to5' -cacheDir = path.join(process.env.ATOM_HOME, 'compile-cache') -# Use separate compile cache when sudo'ing as root to avoid permission issues -if process.env.USER is 'root' and process.env.SUDO_USER and process.env.SUDO_USER isnt process.env.USER - cacheDir = path.join(cacheDir, 'root') - -CoffeeCache.setCacheDirectory(path.join(cacheDir, 'coffee')) -CSON.setCacheDir(path.join(cacheDir, 'cson')) -to5.setCacheDirectory(path.join(cacheDir, 'js')) - # This file is required directly by apm so that files can be cached during # package install so that the first package load in Atom doesn't have to # compile anything. -exports.addPathToCache = (filePath) -> +exports.addPathToCache = (filePath, atomHome) -> + cacheDir = path.join(atomHome, 'compile-cache') + # Use separate compile cache when sudo'ing as root to avoid permission issues + if process.env.USER is 'root' and process.env.SUDO_USER and process.env.SUDO_USER isnt process.env.USER + cacheDir = path.join(cacheDir, 'root') + + CoffeeCache.setCacheDirectory(path.join(cacheDir, 'coffee')) + CSON.setCacheDir(path.join(cacheDir, 'cson')) + to5.setCacheDirectory(path.join(cacheDir, 'js')) + switch path.extname(filePath) when '.coffee' CoffeeCache.addPathToCache(filePath)