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