NPM/React: 复制文件不正确 运行
NPM/React: copyfiles not running correctly
Django 2.0,
Node.js8.11.4
我有一个格式为的 djanog 项目:
reactify/
└── src/
├── reactify-ui/
| ├── build/
| | └── static/
| | └── js/
| | └── main.3425.js
| └── package.json
└── staticfiles/
└── js/
└── reactify-django-us.js
我想用 \reactify\src\reactify-ui\build\static\js\*
中的内容替换 \reactify\src\staticfiles\js
中的内容
我的packages.json
看起来像这样
"scripts": {
...
"copy-build-js": "copyfiles -f 'build/static/js/*.js' '../staticfiles/js/'",,
...
}
当我 运行 npm copy-build-js
我得到以下输出:
> reactify-ui@0.1.0 copy-build-js C:\Users\Owner\dev\reactifydjango\src\reactify-ui
> copyfiles -f 'build/static/js/*.js' '../staticfiles/js/'
它看起来有效,但是当我检查目标位置 ../staticfiles/js/
中的文件时,它并没有改变。
我通过
验证它
changing the file before I run the command,
do an `ls -lrth` to get the timetamp,
wait a minute so the timestamp changes,
run the command `npm copy-build-js`,
and then doing an `ls -lrth` on the target location and seeing that the timestamp isn't post hasn't changed.
I also look at the file and it is the same.
为什么复制文件不起作用?
你的结构是正确的,但是 copyfiles
包有一些你错过的怪癖。将其用作您的脚本:
"copy-build-js": "del /F \"../staticfiles/js\" && copyfiles -E -f \"./build/static/js/*.js\" ../staticfiles/js"
这里的双引号是必需的,所以你需要在每个双引号之前加黑斜线来转义它们。
copyfiles
包没有替换目录中所有文件的选项,即使文件名不存在,所以首先你必须 运行 del /F \"../staticfiles/js\"
删除src/staticfiles/js
目录中的所有文件。此命令假定您在 Windows.
那你运行copyfiles -E -f \"./build/static/js/*.js\" ../staticfiles/js
。你错过的是当使用 wildcards/globs 和这个包 (*
) 时,你必须 double 引用位置。如果位置中没有通配符,则根本不需要引号。我添加了 -E
标志,如果未复制文件,该标志会抛出错误,这可能会在以后为您省去麻烦。
Django 2.0, Node.js8.11.4
我有一个格式为的 djanog 项目:
reactify/
└── src/
├── reactify-ui/
| ├── build/
| | └── static/
| | └── js/
| | └── main.3425.js
| └── package.json
└── staticfiles/
└── js/
└── reactify-django-us.js
我想用 \reactify\src\reactify-ui\build\static\js\*
\reactify\src\staticfiles\js
中的内容
我的packages.json
看起来像这样
"scripts": {
...
"copy-build-js": "copyfiles -f 'build/static/js/*.js' '../staticfiles/js/'",,
...
}
当我 运行 npm copy-build-js
我得到以下输出:
> reactify-ui@0.1.0 copy-build-js C:\Users\Owner\dev\reactifydjango\src\reactify-ui
> copyfiles -f 'build/static/js/*.js' '../staticfiles/js/'
它看起来有效,但是当我检查目标位置 ../staticfiles/js/
中的文件时,它并没有改变。
我通过
changing the file before I run the command,
do an `ls -lrth` to get the timetamp,
wait a minute so the timestamp changes,
run the command `npm copy-build-js`,
and then doing an `ls -lrth` on the target location and seeing that the timestamp isn't post hasn't changed.
I also look at the file and it is the same.
为什么复制文件不起作用?
你的结构是正确的,但是 copyfiles
包有一些你错过的怪癖。将其用作您的脚本:
"copy-build-js": "del /F \"../staticfiles/js\" && copyfiles -E -f \"./build/static/js/*.js\" ../staticfiles/js"
这里的双引号是必需的,所以你需要在每个双引号之前加黑斜线来转义它们。
copyfiles
包没有替换目录中所有文件的选项,即使文件名不存在,所以首先你必须 运行 del /F \"../staticfiles/js\"
删除src/staticfiles/js
目录中的所有文件。此命令假定您在 Windows.
那你运行copyfiles -E -f \"./build/static/js/*.js\" ../staticfiles/js
。你错过的是当使用 wildcards/globs 和这个包 (*
) 时,你必须 double 引用位置。如果位置中没有通配符,则根本不需要引号。我添加了 -E
标志,如果未复制文件,该标志会抛出错误,这可能会在以后为您省去麻烦。