fs-path似乎没有创建正确的文件/文件夹

时间:2018-03-24 16:32:58

标签: javascript node.js fs

所有console.logs都在运行,但根本没有创建文件夹和文件。我做错了什么?

您可以假设定义了this的所有内容



  public writeFiles = () => {
    console.log('writing files');
    const folderPath = `~/dev/generated-projects/${this.projectName}/server/api/routes/${this.structure.name}`;
    console.log('folder path', folderPath);
    fsPath.writeFileSync(path.join(folderPath, 'index.ts'), this.indexFile);
    fsPath.writeFileSync(path.join(folderPath, 'routes.ts'), this.routesFile);
    fsPath.writeFileSync(path.join(folderPath, 'helpers.ts'), this.helperFile);
    console.log('create routes for ', this.structure.name);
  }




1 个答案:

答案 0 :(得分:2)

~是一个shell-ism。您需要将其展开Expanding / Resolving ~ in node.js或直接使用process.env.HOME