我試圖將~/.aws
複製到我的碼頭集裝箱中。但是我在運行git-bash
的Windows機器上,這似乎是導致一些問題。如何在npm腳本中以跨平臺兼容的方式使用〜(home dir)?
兩件事至今我已經試過:
"d-aws-copy": "docker cp ~/.aws constraint-listener:/usr/src/app"
結果:GetFileAttributesEx C:\work\project-name\~: The system cannot find the file specified.
"d-aws-copy": "docker cp /c/Users/user-name-here/.aws constraint-listener:/usr/src/app",
結果:GetFileAttributesEx C:\c: The system cannot find the file specified.
所有我見過涉及波浪線之後的解決方案擴展是針對節點代碼的,而不是針對命令行的npm腳本。
如果我從bash運行docker cp ~/.aws constraint-listener:/usr/src/app
它工作正常。但是在一個npm腳本中,它會像上面看到的那樣崩潰。
我怎樣才能讓~
在Windows機器上的npm腳本中工作?
我認爲這應該對你有所幫助:https://stackoverflow.com/a/9081436/1262789 – Bhavyanshu