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


TypeScript mkdirp.sync函数代码示例

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


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

示例1: Error

        this.files.forEach(function (f) {

            // Validate config
            validate.reset(grunt);
            if (!grunt.file.exists(f.dest)) {
                mkdirp.sync(f.dest);
                if (!validate.exists(f.dest, 'dest')) {
                    return false;
                }
            }

            // Process each folder
            f.src.forEach(function (target) {

                // Validate file target
                if (!validate.exists(target, 'src')) { return false; }
                if (!validate.is_dir(target)) { return false; }

                // Setup actions
                actions.grunt = grunt;
                actions.options = options;
                actions.target = target;
                actions.dest = f.dest;

                // Apply the template if there is one
                if (options.template) {
                  actions.set_template(options.template);
                }

                // Generate output string
                var output_file = actions.output(options.output);

                // Validate the components of this component exist
                var parts = actions.parts();
                if (!validate.exists(parts.script, 'options.scripts in ' + target)) { return false; }
                if (!validate.exists(parts.script, 'options.styles in ' + target)) { return false; }
                if (!validate.exists(parts.script, 'options.markup in ' + target)) { return false; }

                // Generate a component from the parts
                var output = actions.combine(parts);

                // Generate output file
                output = beautify(output, { indent_size: 2 })
                fs.writeFileSync(output_file, output);

                return true;
            });

            if (validate.failed) {
                throw Error('iwc-grunt: errors occurred');
            }
        });
开发者ID:shadowmint,项目名称:iwc-grunt,代码行数:52,代码来源:iwc.ts

示例2: Given

Given('a broken file {string}', async function(filePath) {
  const subdir = path.dirname(filePath)
  if (subdir !== '.') {
    mkdirp.sync(path.join(this.rootDir, subdir))
  }
  await fs.writeFile(
    path.join(this.rootDir, filePath),
    `
      <a href="missing">
      </a>
      `
  )
})
开发者ID:Originate,项目名称:tutorial-runner,代码行数:13,代码来源:given-steps.ts

示例3: constructor

  constructor(storagePath = './storage/storage.json') {
    this.storagePath = storagePath

    try {
      fs.accessSync(storagePath, fs.constants.F_OK)
    } catch (err) {
      mkdirp.sync(path.dirname(storagePath))
      this.writeStorage({})
    }

    const data = fs.readFileSync(this.storagePath, 'utf8')
    this.storage = JSON.parse(data)
  }
开发者ID:ilmaria,项目名称:laskutus-electron,代码行数:13,代码来源:json-storage.ts

示例4: assert

                    .forEach(file => {
                        const result = engine.replaceByRule(file);

                        const target = file.replace(fixtureDir, expectedDir);
                        if (fs.existsSync(target)) {
                            const expected = fs.readFileSync(target, { encoding: "utf8" });
                            assert(result === expected);

                        } else {
                            mkdirp.sync(path.dirname(target));
                            fs.writeFileSync(target, result);
                        }
                    });
开发者ID:vvakame,项目名称:prh,代码行数:13,代码来源:engineSpec.ts

示例5: test

  test('start/stop with existing dir', async () => {
    const quoteAggregator = { onQuoteUpdated: new Map() };
    const spreadAnalyzer = { getSpreadStat: jest.fn() };
    const timeSeries = { put: jest.fn() };
    const config = {};

    const rs = new ReportService(quoteAggregator, spreadAnalyzer, timeSeries, { config });
    mkdirp.sync(rs.reportDir);
    await rs.start();
    expect(quoteAggregator.onQuoteUpdated.size).toBe(1);
    await rs.stop();
    expect(quoteAggregator.onQuoteUpdated.size).toBe(0);
  });
开发者ID:tangkaisky,项目名称:r2,代码行数:13,代码来源:ReportService.test.ts

示例6: saveToLocalDriveAux

    saveToLocalDriveAux(params, callback) {
        let rootdir = path.join(TEMP_UPLOAD_PATH, params.user_id, Util.getNowDateForFile());
        let local_filepath = path.join(rootdir, params.uploadedFile.originalname);
        mkdirp.sync(rootdir);
        var wstream = fs.createWriteStream(local_filepath, { defaultEncoding: 'binary' });
        wstream.write(params.uploadedFile.buffer, (err) => {
            if (err) logging.error(err);
            delete params.uploadedFile.buffer;
            callback();
        });

        params.req.local_uploaded_files = (params.req.local_uploaded_files || []).concat([local_filepath]);
    }
开发者ID:zaksie,项目名称:gotouch,代码行数:13,代码来源:uploader.ts

示例7: _transform

  _transform(node: FilesystemNode, encoding, callback) {
    const input_filepath = node.path;
    const output_filepath = input_filepath.replace(this.input_dirpath, this.output_dirpath);
    mkdirp.sync(dirname(output_filepath))

    if (node.stats.isFile()) {
      transformFile(input_filepath, output_filepath, (error) => {
        callback(error, `${input_filepath} -> ${output_filepath}\n`);
      });
    }
    else {
      callback(null, `ignoring ${input_filepath}\n`);
    }
  }
开发者ID:chbrown,项目名称:fapply,代码行数:14,代码来源:index.ts

示例8: createBrowserPackage

function createBrowserPackage(minify = true) {
    console.log("Minify: " + minify);
    var rootPath = path.join(__dirname, "../../");

    var rootFile = path.join(rootPath, "/dist/index.js");

    var targetFolder = path.join(rootPath, "browserVersion");

    var targetFile = path.join(targetFolder, "raml-suggestions.js");
    
    mkdirp.sync(targetFolder);

    webPackForBrowser(rootPath, rootFile, targetFile, minify);
}
开发者ID:mulesoft,项目名称:raml-suggestions,代码行数:14,代码来源:browserVersionGenerator.ts

示例9: savePageToDisk

function savePageToDisk(location: string, html: string) {
  // public path is one above
  const locationPath = path.join(__dirname, "..", `public${location}`);
  const pathExists = fs.existsSync(locationPath);
  // if the path doesn't exist, create it
  if (pathExists === false) {
    mkdirp.sync(locationPath);
  }
  // create file at path
  fs.writeFile(`${locationPath}/index.html`, html, writeFileErrror => {
    if (writeFileErrror) throw writeFileErrror;
    else console.log(`✅ Saved: ${location}`);
  });
}
开发者ID:anater,项目名称:anater.github.io,代码行数:14,代码来源:index.ts

示例10: setup

export function setup() {
  const base = "./tmp/prefix";

  for (const name of electronLocations) {
    const location = resolve(base, name);
    try {
      mkdirp(location);
      app.setPath(name, location);
    } catch (e) {
      console.warn(`Could not set location ${name} to ${location}: ${e.stack}`);
    }
  }
}
开发者ID:HorrerGames,项目名称:itch,代码行数:13,代码来源:test-paths.ts


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