https://www.npmjs.com/package/cross-env

跨平台运行脚本

The problem

Most Windows command prompts will choke when you set environment variables with NODE_ENV=production like that. (The exception is Bash on Windows, which uses native Bash.) Similarly, there's a difference in how windows and POSIX commands utilize environment variables. With POSIX, you use: $ENV_VAR and on windows you use %ENV_VAR%.

This solution

cross-env makes it so you can have a single command without worrying about setting or using the environment variable properly for the platform. Just set it like you would if it's running on a POSIX system, and cross-env will take care of setting it properly.

The cross-env module exposes two bins: cross-env and cross-env-shell. The first one executes commands using cross-spawn, while the second one uses the shell option from Node's spawn.

The main use case for cross-env-shell is when you need an environment variable to be set across an entire inline shell script, rather than just one command.

For example, if you want to have the environment variable apply to several commands in series then you will need to wrap those in quotes and use cross-env-shell instead of cross-env.

{

"scripts": {

"greet": "cross-env-shell GREETING=Hi NAME=Joe "echo $GREETING && echo $NAME""

}

}

The rule of thumb is: if you want to pass to cross-env a command that contains special shell characters that you want interpreted, then use cross-env-shell. Otherwise stick to cross-env.

cross-env 兼容跨平台运行脚本的更多相关文章

  1. php 运行脚本shell

    F:\phpStudy\php53\php.exe -f F:\phpStudy\WWW\qh\qh.php /usr/local/php/bin/php -f test.php Usage: php ...

  2. Mac Sublime Text使用python3运行脚本(command+b)

    默认安装好sublime, 使用快捷键command+b的时候, 会使用python2版本运行 下面就改为用python3运行, 也可以python2运行 一. 新建文件 Sublime Text - ...

  3. 开源一个跨平台运行的服务插件 - TaskCore.MainForm

    本次将要很大家分享的是一个跨平台运行的服务插件 - TaskCore.MainForm,此框架是使用.netcore来写的,现在netcore已经支持很多系统平台运行了,所以将以前的Task.Main ...

  4. nodejs安装/运行脚本

    本文主要介绍nodejs在windows下安装及运行脚本. 安装nodejs 先从nodejs官网:http://nodejs.org/下载对应的系统的安装包,比如用于64位系统的最新0.10.21的 ...

  5. pycharm运行脚本为何不生成测试报告?

    今日使用python+selenium编写自动化测试脚本并执行过程中,使用pycharm运行结果后发现脚本运行无报错,脚本中的操作也正常被执行,但就是没有生成测试报告. 为什么呢,为什么呢,生成测试报 ...

  6. linux软件管理之------编译安装nginx服务器并手动编写自动化运行脚本

    红帽系列的 linux软件管理分为三类:1. rpm 安装软件.2. yum 安装软件.3. 源码包编译安装.前面两种会在相关专题给出详细讲解.源码包的编译安装是非常关键的,我们知道linux的相关版 ...

  7. 在shell中运行以不同方式运行脚本

    在shell当中,可以有3中方式运行脚本: 1 . ./script_name 或者source ./script_name 2 直接./script_name 3 ./script_name &am ...

  8. mysql下怎样运行脚本

    假设要运行脚本: F:\hello world\niuzi.sql 第一种方法:        在命令行下(未连接数据库),输入 mysql -h localhost -u root  -p < ...

  9. 定时器解决js长时间运行脚本问题

    一般地,单个js操作的运行时间不应超过100毫秒,否则的话,会影响用户体验,用户会认为自己与界面失去联系.而对于一些复杂的任务,可能无法在100ms内完成,甚至会突破浏览器限制(调用栈大小限制和长时间 ...

随机推荐

  1. Camera 涉及的文件70

    点击打开链接 Camera 涉及的文件 1.上电时序 Mediate/custom/$PROJECT/Camera/Camera/kd_camera_hw.c Mediate/custom/$PROJ ...

  2. 利用JQuery直接调用asp.net后台方法

    利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法. [WebMethod]   命名空间 1.无参数的方法调用, 注意:1.方法一定要静态方法,而且要有[WebMethod] ...

  3. Android NFC开发(二)——Android世界里的NFC所具备的条件以及使用方法

    Android NFC开发(二)--Android世界里的NFC所具备的条件以及使用方法 NFC的应用比较广泛,而且知识面也是比较广的,所以就多啰嗦了几句,我还还是得跟着官方文档:http://dev ...

  4. 史上最强Spring mvc入门

    一.SpringMVC基础入门,创建一个HelloWorld程序 1.首先,导入SpringMVC需要的jar包. 2.添加Web.xml配置文件中关于SpringMVC的配置 1 2 3 4 5 6 ...

  5. Unity Web自适应浏览器

    unity web的自适应浏览器比我想象中要更简单,但是这里也只有更改最简单的东西实现了自适应.发布web时,在playersetting里面设置分辨率为你在Game窗口自定义的分辨率大小,以保证内容 ...

  6. PS 滤镜算法原理——照亮边缘

    这个算法原理很简单,对彩色图像的R,G,B 三个通道,分别求梯度,然后将梯度值作为三个通道的值. clc; clear all;Image=imread('4.jpg');Image=double(I ...

  7. PS 滤镜算法原理——拼贴

    %%%% Tile  %%%%% 实现拼贴效果 %%%%% 将原图像进行分块,然后让图像块在 %%%%% 新图像范围内进行随机移动,确定移动后的边界 %%%%% 将移动后的图像块填入新图像内 clc; ...

  8. javascript内置对象速查(一)

    字符串对象 var str = new String("Hello World"); 可以调用其中的一些方法: str.length str.big 日期对象 var dt = n ...

  9. Tomcat的缺省是多少,怎么修改

     Tomcat的缺省端口号是8080. 修改Tomcat端口号: 1.找到Tomcat目录下的conf文件夹 2.进入conf文件夹里面找到server.xml文件 3.打开server.xml文件 ...

  10. Tomcat启动时加载数据到缓存---web.xml中listener加载顺序(优先初始化Spring IOC容器)

    JavaWebSpringTomcatCache  最近用到在Tomcat服务器启动时自动加载数据到缓存,这就需要创建一个自定义的缓存监听器并实现ServletContextListener接口,并且 ...