我试图使用Yarn设置命令来创建目录,构建我的Docker镜像然后启动docker-compose up.
我在我的程序中添加了一个启动脚本package.json来执行shell脚本:
"scripts": {
"start": "./start-docker.sh",
...
}
Run Code Online (Sandbox Code Playgroud)
这是start-docker.sh:
#!/bin/bash
mkdir -p volumes/mysql volumes/wordpress
docker-compose build
docker-compose up
Run Code Online (Sandbox Code Playgroud)
它起初不起作用,因为我的容器无权访问创建的目录.
然后,我在创建目录后添加了这一行,以便为容器提供完全权限:
sudo chmod -R 777 volumes
Run Code Online (Sandbox Code Playgroud)
但正如您所看到的,此命令需要使用sudo执行.这意味着执行yarn start命令要求输入密码,这是我不想要的.
我摆脱了shell脚本并仅使用了yarn脚本:
"scripts": {
"prestart": "mkdir -p volumes/mysql volumes/wordpress && docker-compose build",
"start": "docker-compose up",
...
}
Run Code Online (Sandbox Code Playgroud)
令人惊讶的是它有效,但我不明白为什么......你们有什么想法吗?
package.json来包含-alpha该版本。运行npm version <new version>会package.js增加文件的版本,但是我想在-alpha该版本中添加后缀,但是我无法这样做,因为文档中未对此进行说明,但是semver本身对此提供了支持。
实际结果:
> npm version prerelease
> v0.2.1-1
Run Code Online (Sandbox Code Playgroud)
预期结果:
> v0.2.1-alpha
Run Code Online (Sandbox Code Playgroud) 从带有标志的命令行运行chrome --use-mobile-user-agent不会在移动上下文(用户代理)中打开浏览器.
chrome --use-mobile-user-agent= true
Run Code Online (Sandbox Code Playgroud)
注意:
传递用户代理选项确实有效,但我觉得它不是正确的做事方式,因为chrome为你提供了这个标志,可以在移动环境中启动.
--user-agent= Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; ar) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3
Run Code Online (Sandbox Code Playgroud)
阅读一些铬源代码,我看到以下内容:
kUseMobileUserAgent从"use-mobile-user-agent"标志定义:当Chromium使用移动用户代理时设置.
const char kUseMobileUserAgent[] = "use-mobile-user-agent";
Run Code Online (Sandbox Code Playgroud)
如果我们的变量开关为真/设置,则将"Mobile"添加到产品.
std::string GetShellUserAgent() {
std::string product = "Chrome/" CONTENT_SHELL_VERSION;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kUseMobileUserAgent))
product += " Mobile";
return BuildUserAgentFromProduct(product);
}
Run Code Online (Sandbox Code Playgroud)
作为额外的细节,我使用selenium运行chrome并传递配置:
...
"browserName": "chrome",
"chromeOptions": {
"args": [ …Run Code Online (Sandbox Code Playgroud) ES5 typeof被认为是安全的,因为当再次检查非声明值时它不会抛出ReferenceError.如
console.log(typeof undeclaredVar); // undefined
Run Code Online (Sandbox Code Playgroud)
但是,typeof undeclaredLetConst在es6中检查时,只有在稍后使用let或声明值时才会抛出错误const.如果它是用var声明它将正常工作.
console.log(typeof undeclaredLetConst);
let undeclaredLetConst = "hello"; // ReferenceError
Run Code Online (Sandbox Code Playgroud)
什么事发生在那里?
我知道我们无法访问与我们的域不同的 API。但是,我看到很多人cors在 express 中安装模块以使用 API,然后像这样使用它:
app.use(cors());
Run Code Online (Sandbox Code Playgroud)
它实际上有什么作用?这个功能如何cors在服务器上启用?
node.js ×4
javascript ×2
npm ×2
bash ×1
c++ ×1
chromium ×1
docker ×1
ecmascript-6 ×1
express ×1
selenium ×1
user-agent ×1
yarnpkg ×1