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. Android ViewManager解读之requestLayout() 详解

    尊重原创: http://blog.csdn.net/sk719887916/article/details/48464035 上篇<Android View 中invalidate() 你所不 ...

  2. ubuntu virtualbox xp无声音解决

    太简单了,记录一下解决方法,进入xp,打开设备管理器,对着ac97设备驱动 点右键,点更新驱动,更新一下就ok了. 这时候去控制面板,就可以看到有音频设备了. 具体步骤如下: 第一步,virtualb ...

  3. PCMM(人力资源能力成熟度模型)V2.0中英对照版发布

    PCMM中英版终于发布 时光荏苒,从当初的回眸到如今的回头,这才发现:坚守一份承诺是多么的不易! 一年多了,这份承载殷切期待的作品--<PCMM(人力资源能力成熟度模型)V2.0 (中英文对照版 ...

  4. 生产者消费者的java实现

    先看最简单的,也就是缓冲区的容量为1 缓冲区容量为1 import java.util.List; public class ProducerAndConsumer2 { static class A ...

  5. rabbitMQ之AMQP协议

    1.什么是AMQP协议 即高级消息队列协议,规范客户端与消息中间件服务器之间的通信,并能相互操作. 2.AMQP协议的作用 降低应用程序之间的耦合度,这样不同应用之间的集成的难度将变得更小,并开发出更 ...

  6. android 如何添加第3方lib库到kernel中

    注意:只能将lib库放在kernel编译到的地方,如下: alps/kernel/ alps/mediatek/custom/common/kernel/ alps/mediatek/custom/$ ...

  7. OpenGL下多个sampler在shader中的使用

    在OpenGL中,sampler2D/Cube等做为uniform可以在fragment shader中使用.结合glActiveTexture和glUniform1i,实现texture与sampl ...

  8. 属性动画之ValueAnimator

    原文链接:http://blog.csdn.net/guolin_blog/article/details/43536355

  9. vim配置文件(本人喜欢的风格)

    在/etc/vimrc这个文件 if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set fileencodings=utf ...

  10. IOS微信分享功能简单实现

    PS:此文以简单实现功能为主,不足之前还望指点,大神勿喷. 在此之前如何申请微信认证的Key就不说了,公司一般会有人搞 1.首先下载微信SDK:微信SDK下载地址(更多关于微信SDK信息文档请访问官方 ...