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.

  • 相关阅读:
    java中清空session
    freemarker中修改和添加功能中包含checkbox复选框默认选中需求的解决方式
    Highcharts动态赋值学习
    CSDN Luncher
    JS导入导出Excel表格的方法
    js 下载文件的操作方法
    模板标签的作用
    css3的calc()
    JS滚轮mousewheel事件和DOMMouseScroll事件
    css BFC(格式化上下文)的理解
  • 原文地址:https://www.cnblogs.com/ivanlee-ee-233/p/cross-env.html
Copyright © 2011-2022 走看看