zoukankan      html  css  js  c++  java
  • cross-env 兼容跨平台运行脚本

    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.

  • 相关阅读:
    Git教程
    test
    Android中的权限机制
    Android中<uses-library>的理解
    权限机制
    总是听到有人说AndroidX,到底什么是AndroidX?Android和AndroidX的区别
    VMware Tools按钮变灰色,无法安装的解决方法
    VMware Tools (ubuntu系统)安装详细过程与使用
    Android studio常用快捷键
    CVE漏洞分析
  • 原文地址:https://www.cnblogs.com/ivanlee-ee-233/p/cross-env.html
Copyright © 2011-2022 走看看