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.

  • 相关阅读:
    怎么将ETL技术落地
    vue.js解决刷新404找不到页面问题
    Python 图像识别入门篇
    快速实现CentOS7安装python-pip
    ffmpeg+HLS实现直播与回放
    HBase 二级索引与Coprocessor协处理器
    你做电商死法TOP10:你中了几枪?
    讲讲跳跃表(Skip Lists)
    说框架设计思路
    《Effective Java 第三版》目录汇总
  • 原文地址:https://www.cnblogs.com/ivanlee-ee-233/p/cross-env.html
Copyright © 2011-2022 走看看