當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。