Skip to content

Commit 1aa7738

Browse files
committed
Add WORKSPACE_ADDONS_TEMP_DIR for defining temporary directory for addons
1 parent a21bf62 commit 1aa7738

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

core/cb.addons/main.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function setup(options, imports, register, app) {
1818
// Addons paths
1919
var defaultsPath = path.resolve(options.defaultsPath);
2020
var addonsPath = path.resolve(options.path);
21+
var tempPath = options.tempPath ? path.resolve(options.tempPath) : null;
2122
if (!fs.existsSync(addonsPath)) {
2223
wrench.mkdirSyncRecursive(addonsPath);
2324
}
@@ -99,8 +100,19 @@ function setup(options, imports, register, app) {
99100

100101
logger.log("Install add-on", git);
101102

103+
var createTempDirectory = function() {
104+
if (!tempPath) {
105+
return Q.nfcall(temp.mkdir, 'addons');
106+
} else {
107+
var ret = path.join(tempPath, "t"+Date.now());
108+
return Q.nfcall(fs.mkdir, ret).then(function() {
109+
return Q(ret);
110+
});
111+
}
112+
};
113+
102114
// Create temporary dir
103-
return Q.nfcall(temp.mkdir, 'addon').then(function(dirPath) {
115+
return createTempDirectory().then(function(dirPath) {
104116
// Clone git repo
105117
tempDir = dirPath;
106118
return Q.nfcall(Gift.clone, git, tempDir);

core/codebox.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ var start = function(config) {
3535
'addons': {
3636
// Base path
3737
'path': process.env.WORKSPACE_ADDONS_DIR || path.resolve(__dirname + '/../.addons'),
38-
'defaultsPath': process.env.WORKSPACE_ADDONS_DEFAULTS_DIR || path.resolve(__dirname + '/../addons')
38+
'defaultsPath': process.env.WORKSPACE_ADDONS_DEFAULTS_DIR || path.resolve(__dirname + '/../addons'),
39+
'tempPath': process.env.WORKSPACE_ADDONS_TEMP_DIR
3940
}
4041
});
4142

@@ -88,6 +89,7 @@ var start = function(config) {
8889

8990
// Options
9091
'path': config.addons.path,
92+
'tempPath': config.addons.tempPath,
9193
'defaultsPath': config.addons.defaultsPath
9294
},
9395

docs/addons.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Codebox need two directories for managing addons:
66

77
* A directory for storing defaults addons: WORKSPACE_ADDONS_DEFAULTS_DIR (don't change if you don't know what you're doing)
88
* A directory for storing all the installed addons: WORKSPACE_ADDONS_DIR
9+
* A directory for storing temporary data: WORKSPACE_ADDONS_TEMP_DIR
910

1011
WORKSPACE_ADDONS_DEFAULTS_DIR will be access in read-only mode but WORKSPACE_ADDONS_DIR need write permissions.
1112

0 commit comments

Comments
 (0)