本文整理匯總了TypeScript中fstream.Writer函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Writer函數的具體用法?TypeScript Writer怎麽用?TypeScript Writer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Writer函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: generate_mini_rt
function generate_mini_rt(grunt: IGrunt, outputFile: string, done: (status?: boolean) => void) {
var preloadFiles: string[], i: number, file: string, vendor_dir: string,
dirMap: {[dirName: string]: string[]} = {}, doppio_dir: string,
i: number, file: string, fileDir: string, fileName: string;
if (fs.existsSync(outputFile)) {
// Nothing to do.
return done();
}
grunt.config.requires('build.doppio_dir', 'build.vendor_dir');
doppio_dir = grunt.config('build.doppio_dir');
vendor_dir = grunt.config('build.vendor_dir');
grunt.log.writeln("Generating file " + outputFile + "...");
preloadFiles = fs.readFileSync('tools/preload').toString().split('\n');
if (fs.existsSync('tools/preload-compile-extras')) {
preloadFiles = preloadFiles.concat(fs.readFileSync('tools/preload-compile-extras').toString().split('\n'));
}
// Comb through preloadFiles to figure out which directories hold files we
// care about, and what we should grab from each.
for (i = 0; i < preloadFiles.length; i++) {
file = preloadFiles[i];
fileDir = path.dirname(file);
fileName = path.basename(file);
if (dirMap.hasOwnProperty(fileDir)) {
dirMap[fileDir].push(fileName);
} else {
dirMap[fileDir] = [fileName];
}
// Add parent directories if not present.
do {
fileDir = path.dirname(fileDir);
if (!dirMap.hasOwnProperty(fileDir)) {
dirMap[fileDir] = [];
}
} while (path.resolve(fileDir) !== path.resolve('.'));
}
// Instead of telling fstream directly to pipe a list of files into the tar
// file (impossible with fstreams), we use a filter on the *entire JCL
// directory contents* to tell it which directories and files to include. :(
fstream.Reader({path: vendor_dir, type: 'Directory', filter:
function() {
var relPath: string;
if (this.type === 'File') {
// It's a file. Get its parent directory path relative to the Doppio
// directory, and see if it needs to be preloaded.
relPath = path.relative(doppio_dir, path.dirname(this.path));
return dirMap.hasOwnProperty(relPath) &&
dirMap[relPath].indexOf(path.basename(this.path)) !== -1;
} else {
// Directory. Make sure it's in the index.
relPath = path.relative(doppio_dir, this.path);
return dirMap.hasOwnProperty(relPath);
}
return false;
}
}).pipe(tar.Pack()).pipe(fstream.Writer(outputFile)).on('close', function() { done(); });
}
示例2:
response.on('end', () => {
Debug.info('PHPStubs Download Complete');
Debug.info(`Unzipping to ${this.getStubsDir()}`);
fs.createReadStream(tmp)
.pipe(unzip.Parse())
.pipe(fstream.Writer(this.getStubsDir()));
window.showInformationMessage('PHP Library Stubs downloaded and installed. You may need to re-index the workspace for them to work correctly.', 'Rebuild Now').then(item => {
this.rebuildProject();
});
});
示例3: unpackZipFile
async function unpackZipFile(archivePath: string, unpackPath: string) {
let readStream = createReadStream(archivePath);
let writeStream = fstream.Writer(unpackPath);
console.log(chalk.yellow('Unpacking: ') + archivePath);
return new Promise<void>((resolve, reject) => {
readStream
.pipe(unzip.Parse())
.pipe(writeStream)
.on('close', resolve)
.on('error', reject);
});
}
示例4:
return new Promise<void>((resolve, reject) => {
got.stream(githubArchivePath)
.pipe(fstream.Writer(destArchivePath))
.on('close', resolve)
.on('error', reject);
});