Skip to content

Commit 1a063a1

Browse files
author
Aaron Chambers
committed
Merge pull request #15 from strange-studios/split-file-pattern
Make filePattern config relative to distDir
2 parents f96e548 + 874e88e commit 1a063a1

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'use strict';
33

44
var Promise = require('ember-cli/lib/ext/promise');
5+
var path = require('path');
56
var fs = require('fs');
67

78
var denodeify = require('rsvp').denodeify;
@@ -20,8 +21,9 @@ module.exports = {
2021
defaultConfig: {
2122
host: 'localhost',
2223
port: 6379,
23-
filePattern: function(context) {
24-
return context.distDir + '/index.html';
24+
filePattern: 'index.html',
25+
distDir: function(context) {
26+
return context.distDir;
2527
},
2628
keyPrefix: function(context){
2729
return context.project.name() + ':index';
@@ -30,7 +32,7 @@ module.exports = {
3032
if (context.revisionKey && !context.activatedRevisionKey) {
3133
return "Deployed but did not activate revision " + context.revisionKey + ". "
3234
+ "To activate, run: "
33-
+ "ember activate " + context.revisionKey + " --environment=" + context.deployEnvironment + "\n";
35+
+ "ember deploy:activate " + context.revisionKey + " --environment=" + context.deployEnvironment + "\n";
3436
}
3537
},
3638
revisionKey: function(context) {
@@ -46,19 +48,21 @@ module.exports = {
4648
if (!this.pluginConfig.url) {
4749
['host', 'port'].forEach(this.applyDefaultConfigProperty.bind(this));
4850
}
49-
['filePattern', 'keyPrefix', 'revisionKey', 'didDeployMessage', 'redisDeployClient'].forEach(this.applyDefaultConfigProperty.bind(this));
51+
['filePattern', 'distDir', 'keyPrefix', 'revisionKey', 'didDeployMessage', 'redisDeployClient'].forEach(this.applyDefaultConfigProperty.bind(this));
5052

5153
this.log('config ok');
5254
},
5355

5456
upload: function(/* context */) {
5557
var redisDeployClient = this.readConfig('redisDeployClient');
5658
var revisionKey = this.readConfig('revisionKey');
59+
var distDir = this.readConfig('distDir');
5760
var filePattern = this.readConfig('filePattern');
5861
var keyPrefix = this.readConfig('keyPrefix');
62+
var filePath = path.join(distDir, filePattern);
5963

60-
this.log('Uploading `' + filePattern + '`');
61-
return this._readFileContents(filePattern)
64+
this.log('Uploading `' + filePath + '`');
65+
return this._readFileContents(filePath)
6266
.then(redisDeployClient.upload.bind(redisDeployClient, keyPrefix, revisionKey))
6367
.then(this._uploadSuccessMessage.bind(this))
6468
.then(function(key) {

tests/unit/index-nodetest.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe('redis plugin', function() {
162162

163163
return previous;
164164
}, []);
165-
assert.equal(messages.length, 7);
165+
assert.equal(messages.length, 8);
166166
});
167167
it('adds default config to the config object', function() {
168168
plugin.configure(context);
@@ -191,7 +191,7 @@ describe('redis plugin', function() {
191191
};
192192
plugin.beforeHook(context);
193193
});
194-
it('warns about missing optional filePattern, revisionKey, didDeployMessage, and connection info', function() {
194+
it('warns about missing optional filePattern, distDir, revisionKey, didDeployMessage, and connection info', function() {
195195
plugin.configure(context);
196196
var messages = mockUi.messages.reduce(function(previous, current) {
197197
if (/- Missing config:\s.*, using default:\s/.test(current)) {
@@ -200,7 +200,7 @@ describe('redis plugin', function() {
200200

201201
return previous;
202202
}, []);
203-
assert.equal(messages.length, 6);
203+
assert.equal(messages.length, 7);
204204
});
205205
it('does not add default config to the config object', function() {
206206
plugin.configure(context);
@@ -230,7 +230,7 @@ describe('redis plugin', function() {
230230
};
231231
plugin.beforeHook(context);
232232
});
233-
it('warns about missing optional filePattern, keyPrefix, revisionKey and didDeployMessage only', function() {
233+
it('warns about missing optional filePattern, distDir, keyPrefix, revisionKey and didDeployMessage only', function() {
234234
plugin.configure(context);
235235
var messages = mockUi.messages.reduce(function(previous, current) {
236236
if (/- Missing config:\s.*, using default:\s/.test(current)) {
@@ -239,7 +239,7 @@ describe('redis plugin', function() {
239239

240240
return previous;
241241
}, []);
242-
assert.equal(messages.length, 5);
242+
assert.equal(messages.length, 6);
243243
});
244244

245245
it('does not add default config to the config object', function() {
@@ -272,7 +272,8 @@ describe('redis plugin', function() {
272272
config: {
273273
redis: {
274274
keyPrefix: 'test-prefix',
275-
filePattern: 'tests/index.html',
275+
filePattern: 'index.html',
276+
distDir: 'tests',
276277
revisionKey: '123abc',
277278
redisDeployClient: function(context) {
278279
return context.redisClient || new Redis(context.config.redis);
@@ -309,7 +310,8 @@ describe('redis plugin', function() {
309310
config: {
310311
redis: {
311312
keyPrefix: 'test-prefix',
312-
filePattern: 'tests/index.html',
313+
filePattern: 'index.html',
314+
distDir: 'tests',
313315
revisionKey: '123abc',
314316
redisDeployClient: function(context){ return context.redisClient; }
315317
}
@@ -340,7 +342,8 @@ describe('redis plugin', function() {
340342
config: {
341343
redis: {
342344
keyPrefix: 'test-prefix',
343-
filePattern: 'tests/index.html',
345+
filePattern: 'index.html',
346+
distDir: 'tests',
344347
revisionKey: '123abc',
345348
redisDeployClient: function(context) {
346349
return context.redisClient || new Redis(context.config.redis);
@@ -391,7 +394,7 @@ describe('redis plugin', function() {
391394
plugin.didDeploy(context);
392395
assert.match(messageOutput, /Deployed but did not activate revision 123abc./);
393396
assert.match(messageOutput, /To activate, run/);
394-
assert.match(messageOutput, /ember activate 123abc --environment=qa/);
397+
assert.match(messageOutput, /ember deploy:activate 123abc --environment=qa/);
395398
});
396399
});
397400
});

0 commit comments

Comments
 (0)