Skip to content

Commit

Permalink
feat(templating): add support for .env.example files (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkundel authored Apr 16, 2021
1 parent 7ad35c9 commit 9c40a7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/twilio-run/__tests__/templating/filesystem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ test('installation with an existing dot-env file', async () => {
expect(writeFile).toHaveBeenCalledWith(
join('testing', '.env'),
'# Comment\n' +
'FOO=BAR\n' +
'\n\n' +
'# Variables for function ".env"\n' + // This seems to be a bug but is the output.
'FOO=BAR\n' +
'\n\n' +
'# Variables for function "example"\n' +
'# ---\n' +
'HELLO=WORLD\n',
'utf8'
Expand Down
1 change: 1 addition & 0 deletions packages/twilio-run/src/templating/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export async function getTemplateFiles(
return (
file.name === 'package.json' ||
file.name === '.env' ||
file.name === '.env.example' ||
file.name === 'README.md'
);
})
Expand Down
6 changes: 3 additions & 3 deletions packages/twilio-run/src/templating/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { install, InstallResult } from 'pkg-install';
import {
downloadFile,
fileExists,
mkdir,
readFile,
writeFile,
mkdir,
} from '../utils/fs';
import { logger } from '../utils/logger';
import { TemplateFileInfo } from './data';
Expand Down Expand Up @@ -154,14 +154,14 @@ export async function writeFiles(
path.join(assetsTargetDir, file.directory, file.name)
),
};
} else if (file.type === '.env') {
} else if (file.type === '.env' || file.type === '.env.example') {
return {
title: 'Configuring Environment Variables in .env',
task: async (ctx: any) => {
const output = await writeEnvFile(
file.content,
targetDir,
file.name
namespace
);
ctx.env = output;
},
Expand Down

0 comments on commit 9c40a7f

Please sign in to comment.