-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
40 lines (35 loc) · 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const join = require('path').join;
function jsUrlForEnvironment(config) {
if (config.squarePaymentForm) {
if (config.squarePaymentForm.jsUrl) {
return config.squarePaymentForm.jsUrl;
} else if (config.squarePaymentForm.environment === 'sandbox') {
return 'https://js.squareupsandbox.com/v2/paymentform';
}
}
// If we're in development or test mode, we probably want to use sandbox instead
// of production.
if (config.environment === 'development' || config.environment === 'test') {
return 'https://js.squareupsandbox.com/v2/paymentform';
} else {
return 'https://js.squareup.com/v2/paymentform';
}
}
module.exports = {
name: require('./package').name,
contentFor(type, config) {
if (type === 'head') {
return `<script type="text/javascript" src="${jsUrlForEnvironment(config)}"></script>`;
}
},
treeForPublic: function() {
const imagesDir = new Funnel(join(this.root, 'vendor/images'), {
include: ['*.svg'],
destDir: '/assets/square-payment-form-images'
});
return mergeTrees([imagesDir]);
}
};