sindresorhus/cpy-cli

Not working with .env files

Opened this issue · 3 comments

I am using version "cpy-cli": "^4.2.0",

I am trying to copy ".env.qa" contents to ".env" file in the same directory structure but its not working as intended. Instead of writing the contents, it creates a "/.env/.env.qa" directory & file.

I have tried the --dot and --flat flags but that doesn't solve the problem.

cpy .env.qa .env --dot --flat

I wanted to copy my environment variables from .env.qa or .env.production to .env file so it can be used with .dotenv package.

Duplicate of #29

This is weird. It works without even using the --dot option if I type it directly in console: cpy '.env' build

But in the package.json scripts it will never work no matter where I put the --dot option.

"scripts": {
    "build": "cpy --dot '.env' build"
  },

Sadly because of this the package becomes useless to me

Doesn't work at all in package.json. am I doing something wrong? Works on cli normally and with NPX:

Running at the root of the project. Works:

cpy 'build/data/clientes.json' 'build/data/transmissao.json' 'data' --flat 
npx cpy 'build/data/clientes.json' 'build/data/transmissao.json' 'data' --flat

does not work:

"scripts": {
    "sync": "cpy 'build/data/clientes.json' 'build/data/transmissao.json' 'data' --flat"
  },

I'm not even using 'build/data/*.json' as a possible solution to this, but still won't work.

> npm run sync                                                                  

> npx cpy 'build/data/clientes.json' 'build/data/transmissao.json' 'data' --flat
> cpy 'build/data/clientes.json' 'build/data/transmissao.json' 'data' --flat

Cannot copy `'build/data/clientes.json'`: the file doesn't exist

The files exist in the specified structure, I'm not sure what is wrong with package.json scripts?