deno_task_shell icon indicating copy to clipboard operation
deno_task_shell copied to clipboard

Can't load environment variable with space from .env file

Open sntran opened this issue 2 years ago • 0 comments

Based on https://github.com/denoland/deno_task_shell/issues/30, I added this task in deno.json

{
  "tasks": {
    "echo": "export $(cat .env | xargs) && deno eval \"console.log(Deno.env.get('DATABASE_URL'))\""
  }
}

And my .env file is below:

DATABASE_URL="Provider=MSOLEDBSQL;Data Source=localhost:1433;Initial Catalog=AdventureWorks;User ID=sa;Password=password

When running deno task echo, the following output is produced:

% deno task echo
Task echo export $(cat .env | xargs) && deno eval "console.log(Deno.env.get('DATABASE_URL'))"
Provider=MSOLEDBSQL;Data

Note that the environment variable value is cut off after the first white space.

sntran avatar Dec 21 '23 23:12 sntran