Skip to content

Commit 5b467af

Browse files
author
Niall O'Higgins
committed
make "prepare" command configurable
fixes #5
1 parent 31044ed commit 5b467af

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

config/config.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<input type="text" ng-model="config.prepare" />
2+
<p class="help-text">
3+
Select which command should be used to prepare your project. The default is
4+
"pip -r requirements.txt". For example, this could be "python setup.py
5+
develop" for some projects.
6+
</p>
17
<select ng-model="config.test">
28
<option value="python setup.py test">python setup.py test</option>
39
<option value="make test">make test</option>

webapp.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ module.exports = {
1111
type: String,
1212
enum: ['none', 'py.test', 'python setup.py test', 'make test'],
1313
default: 'python setup.py test'
14+
},
15+
prepare: {
16+
type: String,
17+
default: 'pip install -r requirements.txt'
1418
}
1519
}
1620
}

worker.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@ module.exports = {
99
if (config && config.test !== 'none') {
1010
test = config.test
1111
}
12+
var defaultPrepare = "pip install -r requirements.txt"
13+
var prepare = defaultPrepare
14+
if (config && config.prepare) {
15+
prepare = config.prepare
16+
}
1217
done(null, {
1318
path: [path.join(__dirname, 'thirdparty'),
1419
path.join(venvDir, 'bin')],
1520
environment: 'virtualenv.py ' + venvDir,
1621
prepare: function (context, done) {
17-
if (fs.existsSync(path.join(context.dataDir, 'requirements.txt'))) {
18-
return context.cmd('pip install -r requirements.txt', function (err) {
19-
done(err, true)
20-
})
22+
if (prepare === defaultPrepare && !fs.existsSync(path.join(context.dataDir, 'requirements.txt'))) {
23+
// skip if default and no requirements.txt exists
24+
// we assume that if you're configuring your own, you'll ensure the file exists
25+
return done(null, true)
2126
}
22-
done(null, false)
27+
context.cmd(prepare, function (err) {
28+
done(err, true)
29+
})
2330
},
2431
test: test
2532
})

0 commit comments

Comments
 (0)