Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js mem fs编辑器:如何复制相对符号链接?_Node.js_Yeoman_Yeoman Generator - Fatal编程技术网

Node.js mem fs编辑器:如何复制相对符号链接?

Node.js mem fs编辑器:如何复制相对符号链接?,node.js,yeoman,yeoman-generator,Node.js,Yeoman,Yeoman Generator,我有一个目录,其中包含许多文件和一个(或多个)symlinkname->。symlink。我想将整个目录的内容复制到一个新位置。下面的代码很好地复制了所有内容,尽管它跳过了符号链接。添加globOptions.follow=true只会使其无限循环,这是有意义的,因为它将尝试取消对它的引用。我怎样才能让它复制所有的内容+符号链接而不尝试跟随它们 this.fs.copy( this.destinationPath() + '/**', this.destinationPath('buil

我有一个目录,其中包含许多文件和一个(或多个)
symlinkname->。
symlink。我想将整个目录的内容复制到一个新位置。下面的代码很好地复制了所有内容,尽管它跳过了符号链接。添加
globOptions.follow=true
只会使其无限循环,这是有意义的,因为它将尝试取消对它的引用。我怎样才能让它复制所有的内容+符号链接而不尝试跟随它们

this.fs.copy(
  this.destinationPath() + '/**',
  this.destinationPath('build/html'),
  {
    globOptions: {
      follow: true // This will make the copy loop infinitely, which makes sense. 
    }
  }
});

在发现约曼通过排除对符号链接的支持(参见Simon Boudrias的评论)来避免糟糕的用户体验后,我知道我必须解决这个问题。我做了以下解决方法,请注意,只有当您无法避免像我这样的符号链接时,才应应用此方法

var fs = require('fs');

// Find out if there are symlinks
var files = fs.readdirSync(this.destinationPath());
for (var i = 0; i < files.length; i++) {

  var path = this.destinationPath(files[i]),
      stats = fs.lstatSync(path);

  if (stats.isSymbolicLink()) {

    // Find the target of the symlink and make an identical link into the new location
    var link = fs.readlinkSync(path);
    fs.symlinkSync(link, this.destinationPath('build/html/' + files[i]));
  }
}
var fs=require('fs');
//找出是否有符号链接
var files=fs.readdirSync(this.destinationPath());
对于(var i=0;i
您无法将符号链接发布到npm,不确定这将如何工作。在不了解很多可能的含义的情况下,它听起来应该非常简单,只需将链接复制到特定位置即可?编辑:我不打算向NPM BTW发布任何东西,我只使用YoMaN生成器来支持我的项目,其中包含SysLink。我们也许能够遵循SyLink并把它看作一个文件夹,但是我真的不知道我们如何复制Simulink本身(或者如何使用它)。我们试图用Yeoman做的很多事情是防止糟糕的用户体验,任何对符号链接的特殊处理都会打开一个蠕虫罐。-在mem fs编辑器上随意打开一个问题;我很高兴通过适当的渠道进一步讨论这个问题。目前,符号链接不受支持,因此可能无法使其正常工作(除了
follow:true