forked from mirrors/probot
Merge pull request #171 from gr2m/master
allow to set PRIVATE_KEY with "\\n" characters
This commit is contained in:
commit
ece26960ff
|
@ -16,7 +16,7 @@ function findPrivateKey(filepath) {
|
|||
return fs.readFileSync(filepath);
|
||||
}
|
||||
if (process.env.PRIVATE_KEY) {
|
||||
return process.env.PRIVATE_KEY;
|
||||
return process.env.PRIVATE_KEY.replace(/\\n/g, '\n');
|
||||
}
|
||||
if (process.env.PRIVATE_KEY_PATH) {
|
||||
return fs.readFileSync(process.env.PRIVATE_KEY_PATH);
|
||||
|
|
|
@ -48,6 +48,21 @@ describe('private-key', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('when a PRIVATE_KEY has line breaks', function () {
|
||||
beforeEach(function () {
|
||||
process.env.PRIVATE_KEY = 'line 1\\nline 2';
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
delete process.env.PRIVATE_KEY;
|
||||
});
|
||||
|
||||
it('should return the key', function () {
|
||||
expect(findPrivateKey())
|
||||
.toEqual('line 1\nline 2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when a PRIVATE_KEY_PATH env var is provided', function () {
|
||||
beforeEach(function () {
|
||||
process.env.PRIVATE_KEY_PATH = keyfilePath;
|
||||
|
|
Loading…
Reference in New Issue