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