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


TypeScript klaw.default函数代码示例

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


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

示例1: writeFile

 return new Promise<void>((resolve, reject) => {
   klaw(srcDir)
     .on('data', async (item: klaw.Item) => {
       if (item.path.endsWith('.ts')) {
         try {
           let fileContent = await readFile(item.path);
           await writeFile(
             item.path,
             prettier.format(fileContent.toString(), {
               parser: 'typescript',
               singleQuote: true,
               bracketSpacing: false,
               trailingComma: 'all',
               semi: true,
             }),
           );
           log(`Format the source code successfully:${item.path}`);
         } catch (err) {
           log(`Failed to format the source code:${item.path} ${err}`);
           console.warn(
             `Failed to format the source code:${item.path} ${err}`,
           );
           reject(err);
         }
       }
     })
     .on('end', () => {
       resolve();
     });
 });
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:30,代码来源:cli.ts

示例2: Promise

        return new Promise((resolve, reject) => {
            var klaw: any = require('klaw');
            var members: forceCode.IWorkspaceMember[] = []; // files, directories, symlinks, etc
            klaw(vscode.window.forceCode.workspaceRoot)
                .on('data', function (item) {
                    // Check to see if the file represents an actual member... 
                    if (item.stats.isFile()) {
                        var metadataFileProperties: jsforce.IMetadataFileProperties[] = getMembersFor(item);

                        if (metadataFileProperties.length) {

                            var workspaceMember: forceCode.IWorkspaceMember = {
                                name: metadataFileProperties[0].fullName,
                                path: item.path,
                                memberInfo: metadataFileProperties[0],
                            };
                            members.push(workspaceMember);
                        }
                    }
                })
                .on('end', function () {
                    resolve(members);
                    // console.dir(items) // => [ ... array of files]
                });
        });
开发者ID:mgarf,项目名称:ForceCode,代码行数:25,代码来源:workspace.ts

示例3: readFile

 .then(rstat => {
   if (rstat.isFile()) {
     _createInlineTemplate({
       name: name,
       options: options,
       parameters: parameters,
       path: inputPath,
     })
       .then(t => {
         res({ Template: t.build() });
       })
       .catch(e => {
         rej(e);
       });
   } else if (rstat.isDirectory()) {
     const zip = new jszip();
     const files: Array<string> = [];
     klaw(inputPath)
       .on('data', ({ path: location, stats }) => {
         if (stats.isFile()) {
           files.push(location);
         }
       })
       .on('end', () => {
         if (
           files.length === 1 &&
           relative(inputPath, files[0]) === 'index.js'
         ) {
           _createInlineTemplate({
             name: name,
             options: options,
             parameters: parameters,
             path: files[0],
           })
             .then(t => {
               res({ Template: t.build() });
             })
             .catch(e => {
               rej(e);
             });
         } else {
           bmap(files, file => {
             return readFile(file).then(contents => {
               const relPath = relative(inputPath, file);
               zip.file(relPath, contents);
             });
           }).then(results => {
             zip.generateAsync({ type: 'nodebuffer' }).then(blob => {
               // writeFileSync('final.zip', blob);
               let t = Template()
                 .add(
                   Parameter(`${name}S3BucketParam`, { Type: 'String' })
                 )
                 .add(Parameter(`${name}S3KeyParam`, { Type: 'String' }));
               if (parameters && parameters.length > 0) {
                 parameters.map(p => {
                   t = t.add(Parameter(`${name}${p}`, { Type: 'String' }));
                 });
               }
               t = t
                 .add(
                   Lambda.Function(name, {
                     Code: {
                       S3Bucket: Ref(`${name}S3BucketParam`),
                       S3Key: Ref(`${name}S3KeyParam`),
                     },
                     FunctionName: options.FunctionName,
                     Handler: options.Handler,
                     MemorySize: options.MemorySize,
                     Role:
                       parameters && parameters.includes('Role')
                         ? Ref(`${name}Role`)
                         : options.Role,
                     Runtime: options.Runtime,
                     Timeout: options.Timeout,
                     // Tags: options.Tags ? options.Tags.length > 0 : null
                   })
                 )
                 .putOut(name, `${name}LambdaFunctionOutput`);
               res({
                 Template: t.build(),
                 Zip: blob,
               });
             });
           });
         }
       });
   }
 })
开发者ID:arminhammer,项目名称:wolkenkratzer,代码行数:89,代码来源:lambda.macro.ts

示例4: Promise

 return new Promise((res, rej) => {
   const zip = new jszip();
   const files: Array<string> = [];
   klaw(inputPath)
     .on('data', ({ path: location, stats }) => {
       if (stats.isFile()) {
         files.push(location);
       }
     })
     .on('end', () => {
       bmap(files, file => {
         return readFile(file).then(contents => {
           const relPath = relative(inputPath, file);
           zip.file(relPath, contents);
         });
       }).then(results => {
         zip.generateAsync({ type: 'nodebuffer' }).then(blob => {
           // writeFileSync('final.zip', blob);
           let t = Template();
           let s3BucketVal = Ref(`${name}S3BucketParam`);
           let s3KeyVal = Ref(`${name}S3KeyParam`);
           if (bucket) {
             s3BucketVal = bucket;
             t = t.add(Parameter(`${name}S3BucketParam`, { Type: 'String' }));
           }
           if (key) {
             s3KeyVal = key;
             t = t.add(Parameter(`${name}S3KeyParam`, { Type: 'String' }));
           }
           if (parameters && parameters.length > 0) {
             parameters.map(p => {
               t = t.add(Parameter(`${name}${p}`, { Type: 'String' }));
             });
           }
           const props: any = {
             Code: {
               S3Bucket: s3BucketVal,
               S3Key: s3KeyVal,
             },
             FunctionName: options.FunctionName,
             Handler: options.Handler,
             MemorySize: options.MemorySize,
             Role:
               parameters && parameters.includes('Role')
                 ? Ref(`${name}Role`)
                 : options.Role,
             Runtime: options.Runtime,
             Timeout: options.Timeout,
             // Tags: options.Tags ? options.Tags.length > 0 : null
           };
           if (Object.keys(options.Environment).length > 0) {
             props.Environment = options.Environment;
           }
           if (options.Tags.length > 0) {
             props.Tags = options.Tags;
           }
           const fn = Lambda.Function(name, props);
           res({
             FunctionResource: fn,
             Zip: blob,
           });
         });
       });
     });
 });
开发者ID:arminhammer,项目名称:wolkenkratzer,代码行数:65,代码来源:lambda.macro.ts


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