forked from twilio/twilio-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Makes file paths with tildes work for email:send (twilio#218)
Supplying a file path for an email attachment with a tilde to mean the home directory when using email:send fails. Node.js doesn't support expanding ~ to os.homedir() by default, but the untildify package does create a safe way to achieve this. I worked on this because I tried to send an attachment a number of times with files that definitely existed, but the CLI was telling me they couldn't be found. When I finally used an absolute path, it worked. I'd like to remove that frustration from anyone else that tries.
- Loading branch information
Showing
4 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
const { resolve } = require('path'); | ||
|
||
const sinon = require('sinon'); | ||
const { expect, test } = require('@twilio/cli-test'); | ||
const { Config, ConfigData } = require('@twilio/cli-core').services.config; | ||
const tildify = require('tildify'); | ||
|
||
const emailSend = require('../../../src/commands/email/send'); | ||
|
||
|
@@ -236,6 +239,15 @@ describe('commands', () => { | |
.catch(/Unable to read the file/) | ||
.it('run email:send using flags to set information using invalid file path'); | ||
|
||
defaultSetup({ | ||
toEmail: '[email protected]', | ||
flags: ['--attachment', tildify(resolve('test/commands/email/test.txt'))], | ||
}) | ||
.do((ctx) => ctx.testCmd.run()) | ||
.it('run email:send using flags to set information using tilde in file path', (ctx) => { | ||
expect(ctx.stderr).to.contain('test.txt'); | ||
}); | ||
|
||
defaultSetup({ toEmail: '[email protected]', attachmentVerdict: true }) | ||
.do((ctx) => ctx.testCmd.run()) | ||
.it( | ||
|