当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs.mkdirSync函数代码示例

本文整理汇总了TypeScript中fs.mkdirSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mkdirSync函数的具体用法?TypeScript mkdirSync怎么用?TypeScript mkdirSync使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mkdirSync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: catch

 options.renderer.render(options.indexFilename, config, (err, html) => {
   if (err) {
     console.log(err);
     return;
   }
   try {
     fs.accessSync(options.targetPath);
   } catch (e) {
     fs.mkdirSync(options.targetPath);
   }
   console.log(html);
   const mifiedHtml = minify(html, {
     minifyCSS: true,
     minifyJS: true,
     removeComments: true,
     collapseWhitespace: true
   });
   // console.log(mifiedHtml);
   fs.writeFileSync(`${options.targetPath}/index.html`, mifiedHtml);
 });
开发者ID:narr,项目名称:webpack-angular2-example,代码行数:20,代码来源:generator.ts

示例2: it

 it('should find no files when the given extension has no files', function(finished) {
   fsExtra.removeSync(__dirname + '/tmp');
   fs.mkdirSync(__dirname + '/tmp');
   fs.writeFileSync(__dirname + '/tmp/test.value', '');
   const sequence: LazySequence.Sequence<
     File.AbsoluteFilePath
   > = ParallelProcessQueue.findFiles(
     File.getAbsoluteFilePath(__dirname + '/tmp'),
     'enumValue',
   );
   const future: Promise.Future<
     File.AbsoluteFilePath[]
   > = LazySequence.evaluate(sequence);
   Promise.then(function(fileLocations: File.AbsoluteFilePath[]) {
     expect(fileLocations).toEqualJSON([]);
     fs.unlinkSync(__dirname + '/tmp/test.value');
     fs.rmdirSync(__dirname + '/tmp');
     finished();
   }, future);
 });
开发者ID:facebook,项目名称:remodel,代码行数:20,代码来源:parallel-process-queue-test.ts

示例3: resolve

  return targetDir.split(sep).reduce((parentDir: any, childDir: any) => {
    const curDir = resolve(baseDir, parentDir, childDir);
    try {
      mkdirSync(curDir);
    } catch (err) {
      if (err.code === 'EEXIST') {
        return curDir;
      }
      if (err.code === 'ENOENT') {
        throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
      }

      const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
      if (!caughtErr || (caughtErr && targetDir === curDir)) {
        throw err;
      }
    }

    return curDir;
  }, initDir);
开发者ID:laquereric,项目名称:wexond,代码行数:20,代码来源:storage-area.ts

示例4: if

    const newPath = parts.reduce((tempPath: string, part: string) => {
      // if (tempPath === '') {
      //   return part;
      // }

      const withoutPlus = path.join(tempPath, part);
      const withPlus = path.join(tempPath, '+' + part);
      if (fs.existsSync(withoutPlus)) {
        return withoutPlus;
      } else if (fs.existsSync(withPlus)) {
        return withPlus;
      }

      // Folder not found, create it, and return it
      const dasherizedPart = stringUtils.dasherize(part);
      const dasherizedDirName = path.join(tempPath, dasherizedPart);
      fs.mkdirSync(dasherizedDirName);
      return dasherizedDirName;

    }, parsedOutputPath.root);
开发者ID:dahang,项目名称:angular-cli,代码行数:20,代码来源:dynamic-path-parser.ts

示例5: startEnsimeServer

// Start ensime server. If classpath file is out of date, make an update first
function startEnsimeServer(parsedDotEnsime: DotEnsime) {
    log.debug('starting Ensime server for', parsedDotEnsime.rootDir)
    vscode.window.showInformationMessage("Starting Ensime server")
    if (!fs.existsSync(parsedDotEnsime.cacheDir)) {
        fs.mkdirSync(parsedDotEnsime.cacheDir)
    }

    const ensimeConfig = vscode.workspace.getConfiguration('Ensime')
    const ensimeServerVersion = ensimeConfig.get('ensimeServerVersion').toString()

    const ensimeServerFlags = ensimeConfig.get('ensimeServerFlags').toString()
    const assemblyJar = mkAssemblyJarFilename(parsedDotEnsime.scalaEdition, ensimeServerVersion)

    if(fs.existsSync(assemblyJar)) {
        log.debug('starting from assemblyJar')
        return startServerFromAssemblyJar(assemblyJar, parsedDotEnsime, ensimeServerVersion, ensimeServerFlags)
    } else {
        log.debug('starting from classpath file (coursier)')
        let cpF = mkClasspathFilename(parsedDotEnsime.scalaVersion, ensimeServerVersion)
        const startFromCPFile = () => startServerFromFile(cpF, parsedDotEnsime, ensimeServerVersion, ensimeServerFlags)
    
        if(!classpathFileOk(cpF)) {
            log.debug('No classpath file found matching versions, creating with coursier')
            return fileUtils.ensureExists(packageDir()).then((packageDir) => {
                const p = updateEnsimeServerWithCoursier(parsedDotEnsime, ensimeServerVersion, cpF)
                return p.then(
                    (thang) => {
                        log.debug('got thang', thang, 'starting from cp file')
                        return startFromCPFile();
                    },
                    (failure) => {
                        log.error(failure)
                    }
                    )
            });
        } else {
            log.debug('classpath file ok, using')
            return startFromCPFile()
        }
    }
}
开发者ID:hedefalk,项目名称:ensime-vscode,代码行数:42,代码来源:ensime-startup.ts

示例6: saveEvents

  function saveEvents() {
    const tempFolder = path.join(__dirname, '../temp');
    console.log(tempFolder);

    if (!fs.existsSync(tempFolder)) {
      fs.mkdirSync(tempFolder);
    }
    const time = new Date()
      .toISOString()
      .replace(/[-|:]/g, '_')
      .replace(/\..+/, '');
    const fileName = `replay_${time}.html`;
    const content = `
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Record @${time}</title>
    <link rel="stylesheet" href="../dist/rrweb.min.css" />
  </head>
  <body>
    <script src="../dist/rrweb.min.js"></script>
    <script>
      /*<!--*/
      const events = ${JSON.stringify(events).replace(
        /<\/script>/g,
        '<\\/script>',
      )};
      /*-->*/
      const replayer = new rrweb.Replayer(events);
      replayer.play();
    </script>
  </body>
</html>  
    `;
    const savePath = path.resolve(tempFolder, fileName);
    fs.writeFileSync(savePath, content);
    console.log(`Saved at ${savePath}`);
  }
开发者ID:aftabnaveed,项目名称:rrweb,代码行数:41,代码来源:repl.ts

示例7: start

    public start() {
        try {
            if (!fs.existsSync(IMAGE_PATH)) {
                fs.mkdirSync(IMAGE_PATH);
            }
        } catch (e) {
            logger.exception(e);
            return;
        }

        if (!this.cameraProcess) {
            let fullPath = `${IMAGE_PATH}/${IMAGE_NAME}`;
            this.cameraProcess = spawn("raspistill", [
                "-rot", "0",
                "-w", "640",
                "-h", "480",
                "-q", "5",
                "-o", fullPath,
                "-tl", "100",
                "-t", "9999999",
                "-th", "0:0:0"
            ]);

            this.cameraProcess.on("exit", () => {
                console.log("camera process has stopped");
                this.cameraProcess = null;
            });
        }

        if (!this.streamingProcess) {
            this.streamingProcess = spawn("mjpg_streamer", [
                "-i", `/usr/local/lib/input_file.so -f ${IMAGE_PATH} -n ${IMAGE_NAME}`,
                "-o", "/usr/local/lib/output_http.so -w /usr/local/www"
            ]);

            this.streamingProcess.on("exit", () => {
                console.log("streaming process has stopped");
                this.streamingProcess = null;
            });
        }
    }
开发者ID:UmairB,项目名称:makeblock,代码行数:41,代码来源:Camera.ts

示例8: run

  /**
   * Create the text files and then zip them up using a CLI command that hopefully exists.
   */
  public async run(argv: string[]): Promise<void> {
    const filename = argv[3] || "./gtfs.zip";

    if (fs.existsSync(filename)) {
      fs.unlinkSync(filename);
    }

    argv[3] = "/tmp/gtfs/";

    if (!fs.existsSync(argv[3])) {
      fs.mkdirSync(argv[3]);
    }

    await this.command.run(argv);

    // when node tells you it's finished writing a file, it's lying.
    setTimeout(() => {
      console.log("Writing " + filename);
      execSync(`zip -j ${filename} ${argv[3]}/*.txt`);
    }, 1000);
  }
开发者ID:linusnorton,项目名称:uk-rail-import,代码行数:24,代码来源:OutputGTFSZipCommand.ts

示例9: mkdirp

		function mkdirp(dir: string) {
			if (!dir) {
				return;
			}

			try {
				mkdirSync(dir);
			}
			catch (error) {
				// A parent directory didn't exist, create it
				if (error.code === 'ENOENT') {
					mkdirp(dirname(dir));
					mkdirp(dir);
				}
				else {
					if (!statSync(dir).isDirectory()) {
						throw error;
					}
				}
			}
		}
开发者ID:jason0x43,项目名称:digdug,代码行数:21,代码来源:util.ts

示例10: beforeEach

beforeEach("set logger", async function () {
	if (!this.currentTest)
		return;
	const logFolder = process.env.DC_TEST_LOGS || path.join(ext.extensionPath, ".dart_code_test_logs");
	if (!fs.existsSync(logFolder))
		fs.mkdirSync(logFolder);
	const logFile = filenameSafe(this.currentTest.fullTitle()) + ".txt";
	const logPath = path.join(logFolder, logFile);

	const logger = logTo(logPath);

	deferUntilLast(async (testResult?: "passed" | "failed") => {
		await logger.dispose();
		// On CI, we delete logs for passing tests to save money on S3 :-)
		if (process.env.CI && testResult === "passed") {
			try {
				fs.unlinkSync(logPath);
			} catch { }
		}
	});
});
开发者ID:DanTup,项目名称:Dart-Code,代码行数:21,代码来源:helpers.ts


注:本文中的fs.mkdirSync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。