-
-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generic): allow specifying a build identifier that segregates bu…
…ild artifacts
- Loading branch information
1 parent
32f2bff
commit 0e48365
Showing
5 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const path = require('path'); | ||
|
||
const BASE_OUT_DIR = 'out'; | ||
|
||
export default (baseDir, forgeConfig) => { | ||
if (forgeConfig.buildIdentifier) { | ||
let identifier = forgeConfig.buildIdentifier; | ||
if (typeof identifier === 'function') { | ||
identifier = identifier(); | ||
} | ||
if (identifier) return path.resolve(baseDir, BASE_OUT_DIR, identifier); | ||
} | ||
return path.resolve(baseDir, BASE_OUT_DIR); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect } from 'chai'; | ||
import path from 'path'; | ||
|
||
import getCurrentOutDir from '../../src/util/out-dir'; | ||
|
||
describe('out-dir', () => { | ||
const DIR = __dirname; | ||
|
||
describe('getCurrentOutDir', () => { | ||
it('resolves to the default out directory when nothing extra is declared', () => { | ||
expect(getCurrentOutDir(DIR, {})).to.equal(`${DIR}${path.sep}out`); | ||
}); | ||
|
||
it('resolves to the provided identifier', () => { | ||
expect(getCurrentOutDir(DIR, { | ||
buildIdentifier: 'bar', | ||
})).to.equal(`${DIR}${path.sep}out${path.sep}bar`); | ||
}); | ||
|
||
it('resolves to the return value of provided identifier getter', () => { | ||
expect(getCurrentOutDir(DIR, { | ||
buildIdentifier: () => 'thing', | ||
})).to.equal(`${DIR}${path.sep}out${path.sep}thing`); | ||
}); | ||
}); | ||
}); |