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

Atom gpp编译错误:Nodejs child_进程。在cwd中生成空白

  •  0
  • user3053216  · 技术社区  · 8 年前

    我刚刚安装了Atom编辑器和gpp包 https://github.com/livace/atom-gpp 编译并运行c++。当我运行时,我得到一个错误,说没有这样的文件或目录。

    我认为这是因为我的目录路径中有一个空格。我检查了gpp插件的源代码,发现:

    const options = (file.path + ' -o ' + compiledPath + ' ' + atom.config.get('gpp.compilerOptions')).replace(/[\s{2,}]+/g, ' ').trim();
    
    path.join(filePath.dir, filePath.name);
    
    const child = child_process.spawn('g++', options.split(' '), {
      cwd: filePath.dir
    });
    

    我以前从未使用过nodeJs,但我认为这会导致错误。知道如何使用目录路径(cwd)中的空白来实现这一点吗?

    1 回复  |  直到 8 年前
        1
  •  0
  •   user3053216    8 年前

    我找到了解决方法。在索引中。gpp插件的js,更改

    const options = (file.path + ' -o ' + compiledPath + ' ' + atom.config.get('gpp.compilerOptions')).replace(/[\s{2,}]+/g, ' ').trim();
    
    path.join(filePath.dir, filePath.name);
    console.log(options.split(' '));
    const child = child_process.spawn('g++', options.split(' '), {
      cwd: filePath.dir
    });
    

      const options = atom.config.get('gpp.compilerOptions').replace(/[\s{2,}]+/g, ' ').trim();
    
      path.join(filePath.dir, filePath.name);
      var new_options = [file.path,'-o',compiledPath]
      if (options != ""){
        new_options = new_options.concat(options.split(' '));
      }
      const child = child_process.spawn('g++', new_options, {
        cwd: filePath.dir
      });
    
    推荐文章