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.

  • 相关阅读:
    CLR 对比 JVM
    unity drawcall测试
    UGUI 分页渐变居中效果
    几个ADB常用命令
    jQuery分步步骤
    jquery toast插件
    jQuery数字滚动(模拟网站人气、访问量递增)原创
    jQuery实用工具集
    scrollReveal.js – 页面滚动显示动画JS
    jquery轻量级数字动画插件jquery.countup.js
  • 原文地址:https://www.cnblogs.com/ivanlee-ee-233/p/cross-env.html
Copyright © 2011-2022 走看看