代码之家  ›  专栏  ›  技术社区  ›  khollenbeck

如何在命令行上设置基本路径?

  •  1
  • khollenbeck  · 技术社区  · 11 年前

    细节:

    我有一个这样的目录结构。

     myapp
        root-one
           -web
             -app
             -tests
        root-two
           -grunt
              node_modules
                 .bin
                   intern-runner
                   selenium-standalone
                 intern
                 selenium-standalone
                 grunt-shell
              Gruntfile.js
    

    从我的grut文件中,我使用shell npm启动selenium独立服务器,就像这样。。

    shell: {
       intern : {
          options: { stdout: true},
             command: [
                "cd node_modules/.bin",
                "start selenium-standalone start",
                "intern-runner config=tests/intern basePath=../../../../root-one/web"
             ].join('&&')
          }
       }
    }
    
    grunt.registerTask('intern', ['shell:intern']);
    

    运行我的咕哝命令后 普通实习生 ,selenium开始了,但我从实习生runner那里得到了以下错误。

    Error: Failed to load module tests/intern 
    from C:/myapp/root-two/grunt/node_modules/.bin/tests/intern.js
    

    现在,因为我使用 basePath=../../../../root-one/web 。我本以为它会尝试从 C:/myapp/root-one/web/tests/intern.js 而不是留在 .bin 目录

    问题:

    所以真正的问题是,在命令行上为实习生runner设置basePath的正确方法是什么?因为这似乎行不通。根据 docs ...

    您还可以指定任何有效的 configuration option 作为关于 命令行。

    这让我相信我可能只是语法错误。

    1 回复  |  直到 10 年前
        1
  •  0
  •   khollenbeck    11 年前

    听起来这并不像我期望的那样奏效。正如这里所讨论的: https://github.com/theintern/intern/issues/449

    因此,目前的工作是在全球范围内安装实习生,而不是在我的项目中本地运行。所以我反而。。

    npm install intern -g
    

    我的项目结构如此。。。

     myapp
        root-one
           -web
             -app
             -tests
        root-two
           -grunt
              node_modules
                 .bin
                   selenium-standalone
                 selenium-standalone
                 grunt-shell
              Gruntfile.js
    

    基本上只是删除了interior,因为它现在已在全球安装。位于以下窗口中。。

    C:\Users\user\AppData\Roaming\npm\node_modules\intern
    

    我的Gruntfile也在以下方面有所改变。启动selenium后,我将目录更改回适当的位置,以运行 intern-runner 命令

    shell: {
       intern : {
          options: { stdout: true},
             command: [
                "cd node_modules/.bin",
                "start selenium-standalone start",
                "cd ../../../../root-one/web",
                "intern-runner config=tests/intern
             ].join('&&')
          }
       }
    }
    
    grunt.registerTask('intern', ['shell:intern']);