Skip to content

Commit

Permalink
feat: allow override of local directory path
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Oct 23, 2018
1 parent 88ead7e commit 854f2b5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config.js
Expand Up @@ -155,7 +155,8 @@ const schema = {
path: {
doc: 'The path to the image directory',
format: String,
default: './images'
default: './images',
allowDomainOverride: true
}
},
s3: {
Expand Down
2 changes: 1 addition & 1 deletion dadi/lib/storage/disk.js
Expand Up @@ -6,7 +6,7 @@ const path = require('path')
const Missing = require(path.join(__dirname, '/missing'))

const DiskStorage = function ({assetType = 'assets', domain, url}) {
let assetPath = config.get(`${assetType}.directory.path`)
let assetPath = config.get(`${assetType}.directory.path`, domain)

if (url !== '') {
this.url = nodeUrl.parse(url, true).pathname
Expand Down
22 changes: 22 additions & 0 deletions test/acceptance/multi-domain.js
Expand Up @@ -269,6 +269,28 @@ describe('Multi-domain', function () {
})
}).timeout(5000)

it('should retrieve a local image from the path specified by the domain config', () => {
config.set('images.directory.enabled', true, 'localhost')
config.set('images.directory.path', 'test/images/next-level', 'localhost')
config.set('images.remote.enabled', false, 'localhost')

let DiskStorage = require(path.join(__dirname, '../../dadi/lib/storage/disk'))
let diskStorage = new DiskStorage({
assetType: 'images',
domain: 'localhost',
url: '/test.jpg'}
)

diskStorage.path.should.eql(path.resolve('./test/images/next-level'))

return help.imagesEqual({
base: images['localhost'],
test: `${help.proxyUrl}/test.jpg?mockdomain=localhost`
}).then(match => {
match.should.eql(true)
})
}).timeout(5000)

it('should retrieve a remote image from the path specified by the domain config', () => {
return help.imagesEqual({
base: images['localhost'],
Expand Down

0 comments on commit 854f2b5

Please sign in to comment.