zoukankan      html  css  js  c++  java
  • node_modules .bin文件夹下的文件

    node_modues/.bin文件夹下,对于一个npm包,有两个可执行文件,没有后缀名的是是对应unix系的shell脚本,.cmd文件对应的是windows bat脚本,内容都是用node执行一个js文件

    @IF EXIST "%~dp0
    ode.exe" (
      "%~dp0
    ode.exe"  "%~dp0..webpackinwebpack.js" %*
    ) ELSE (
      @SETLOCAL
      @SET PATHEXT=%PATHEXT:;.JS;=;%
      node  "%~dp0..webpackinwebpack.js" %*
    )
    

    这里是windows的cmd中的语法 ~dp0指执行脚本的当前目录 这句话的意思是如果当前目录下有node.exe,就用node.exe执行... ...webpack.js文件 %*是指执行bat时命令中输入的后续参数 否则 @SETLOCAL设置本次批处理命令中的环境变量 PATHEXT是windows下的文件扩展名环境变量 后面的语法是从PATHEXT中删除.JS 然后执行 node ... ... webpack.js 命令, 去除掉扩展名的作用是为了防止执行到node.js文件 比如当前文件夹下有一个node.js文件, 如果直接执行node命令可能会默认用vscode打开这个.js文件

     

    https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal

    https://stackoverflow.com/questions/112055/what-does-d0-mean-in-a-windows-batch-file

     

     

    另一个不带.cmd结尾的是为unix系统准备的:

     

    #!/bin/sh

    # $()  https://www.cnblogs.com/chengd/p/7803664.html 做命令替换的
    # sed  https://www.runoob.com/linux/linux-comm-sed.html    https://stackoverflow.com/questions/38934138/what-result-do-sed-s-g-and-egrep-example-variablename-give
    # $0   https://unix.stackexchange.com/questions/280454/what-is-the-meaning-of-0-in-the-bash-shell
     

    # 获取当前执行bash的dirname( strip last component from file name ),命名为basedir这个变量
    basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")
     

    # 如果uname 以 *开头 中间有CYGWIN后面有*结束  basedir是 cygpath -w "$basedir"
    # cygpath -w 是以windows风格路径分割符处理$basedir
    # case...in...esac语法 http://c.biancheng.net/view/2767.html
    case `uname` in
        *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
    esac

    # if[]...then...else...fi语法 https://blog.csdn.net/puqutogether/article/details/45815003
    # $@ 代表所有参数 https://superuser.com/questions/694501/what-does-mean-as-a-bash-script-function-parameter
    # $?代表最近执行的返回值 https://unix.stackexchange.com/questions/7704/what-is-the-meaning-of-in-a-shell-script
    # -x 如果后面文件存在是true http://man7.org/linux/man-pages/man1/dash.1.html (-x file)
    if [ -x "$basedir/node" ]; then
      "$basedir/node"  "$basedir/../webpack/bin/webpack.js" "$@"
      ret=$?
    else 
      node  "$basedir/../webpack/bin/webpack.js" "$@"
      ret=$?
    fi

    exit $ret
  • 相关阅读:
    迭代器相关整理
    闭包的功能举例
    函数参数相关整理
    python中进制转换及IP地址转换
    dD Geometry Kernel ( Geometry Kernels) CGAL 4.13 -User Manual
    2D and 3D Linear Geometry Kernel ( Geometry Kernels) CGAL 4.13 -User Manual
    Monotone and Sorted Matrix Search ( Arithmetic and Algebra) CGAL 4.13 -User Manual
    Algebraic Kernel ( Arithmetic and Algebra) CGAL 4.13 -User Manual
    数论中的环概念
    QT的配置及目录结构
  • 原文地址:https://www.cnblogs.com/eret9616/p/11512575.html
Copyright © 2011-2022 走看看