本文整理汇总了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');
}
});
示例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>
`
)
})
示例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)
}
示例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);
}
});
示例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);
});
示例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]);
}
示例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`);
}
}
示例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);
}
示例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}`);
});
}
示例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}`);
}
}
}