Best JavaScript code snippet using fast-check-monorepo
compiler.spec.js
Source:compiler.spec.js
...4 */5var expect = require('expect.js');6var Compiler = require('../src/compiler');7describe('Compiler', function () {8 function createFile(moduleId, deps) {9 var contents = deps10 ? new Buffer('define(' + JSON.stringify(deps) + ', function () { return "' + moduleId + '"});')11 : new Buffer('define(function () { return "' + moduleId + '"});');12 return {13 contents: contents14 };15 }16 it('toSingle (paths)', function () {17 var moduleConfig = {18 baseUrl: 'src',19 paths: {20 tpl: 'common/tpl',21 js: 'common/js'22 }23 };24 var compiler = new Compiler(moduleConfig);25 compiler.registerModuleIds(['app'], createFile('app', ['js!//www.baidu.com/relay.js', 'tpl!./a.tpl.html']));26 var moduleId = 'app';27 expect(compiler.toSingle(moduleId)).to.eql(28 'define(\'app\', [\n \'js!//www.baidu.com/relay.js\',\n \'tpl!./a.tpl.html\'\n], function () {\n return \'app\';\n});');29 });30 it('toSingle (not amd)', function () {31 var moduleConfig = {};32 var compiler = new Compiler(moduleConfig);33 compiler.registerModuleIds(['app'], {34 contents: new Buffer('var app = 10;')35 });36 var moduleId = 'app';37 expect(compiler.toSingle(moduleId)).to.eql('var app = 10;');38 });39 it('toSingle', function () {40 var moduleConfig = {};41 var compiler = new Compiler(moduleConfig);42 compiler.registerModuleIds(['app'], createFile('app'));43 var moduleId = 'app';44 expect(compiler.toSingle(moduleId)).to.eql(45 'define(\'app\', [], function () {\n return \'app\';\n});');46 });47 it('toSingle (package)', function () {48 var moduleConfig = {49 packages: [50 {51 name: 'er',52 location: '../dep/er/0.0.0/src',53 main: 'main'54 },55 {56 name: 'etpl',57 location: '../dep/etpl/0.0.0/src'58 },59 {60 name: 'inf-ria',61 location: '../dep/inf-ria/0.0.0/src',62 main: 'startup.js'63 }64 ]65 };66 var compiler = new Compiler(moduleConfig);67 compiler.registerModuleIds(['er', 'er/main'], createFile('er'));68 compiler.registerModuleIds(['er/View'], createFile('er/View'));69 compiler.registerModuleIds(['etpl', 'etpl/main'], createFile('etpl'));70 compiler.registerModuleIds(['etpl/tpl'], createFile('etpl/tpl'));71 compiler.registerModuleIds(['inf-ria', 'inf-ria/startup'], createFile('inf-ria'));72 compiler.registerModuleIds(['inf-ria/main'], createFile('inf-ria/main'));73 var erPkgBundle = 'define(\'er/main\', [], function () {\n return \'er\';\n});'74 + '\n\n'75 + 'define(\'er\', [\'er/main\'], function (main) { return main; });';76 var etplPkgBundle = 'define(\'etpl/main\', [], function () {\n return \'etpl\';\n});'77 + '\n\n'78 + 'define(\'etpl\', [\'etpl/main\'], function (main) { return main; });';79 var infRiaPkgBundle = 'define(\'inf-ria/startup\', [], function () {\n return \'inf-ria\';\n});'80 + '\n\n'81 + 'define(\'inf-ria\', [\'inf-ria/startup\'], function (main) { return main; });';82 expect(compiler.toSingle('er')).to.eql(erPkgBundle);83 expect(compiler.toSingle('er/View')).to.eql(84 'define(\'er/View\', [], function () {\n return \'er/View\';\n});');85 expect(compiler.toSingle('er/main')).to.eql(erPkgBundle);86 expect(compiler.toSingle('etpl')).to.eql(etplPkgBundle);87 expect(compiler.toSingle('etpl/tpl')).to.eql(88 'define(\'etpl/tpl\', [], function () {\n return \'etpl/tpl\';\n});');89 expect(compiler.toSingle('etpl/main')).to.eql(etplPkgBundle);90 expect(compiler.toSingle('inf-ria')).to.eql(infRiaPkgBundle);91 expect(compiler.toSingle('inf-ria/main')).to.eql(92 'define(\'inf-ria/main\', [], function () {\n return \'inf-ria/main\';\n});');93 });94 it('toPackage', function () {95 var moduleConfig = {96 packages: [97 {98 name: 'er',99 location: '../dep/er/0.0.0/src'100 },101 {102 name: 'underscore',103 location: '../dep/underscore/0.0.0/src'104 },105 {106 name: 'eoo',107 location: '../dep/eoo/0.0.0/src'108 }109 ]110 };111 var compiler = new Compiler(moduleConfig);112 compiler.registerModuleIds(['eoo', 'eoo/main'], createFile('eoo'));113 compiler.registerModuleIds(['underscore', 'underscore/main'], createFile('underscore'));114 compiler.registerModuleIds(['er', 'er/main'], createFile('er'));115 compiler.registerModuleIds(['er/View'], createFile('er/View'));116 compiler.registerModuleIds(['er/Action'], createFile('er/Action', ['eoo', 'underscore']));117 compiler.registerModuleIds(['er/URL'], createFile('er/URL'));118 compiler.registerModuleIds(['er/locator'], createFile('er/locator'));119 compiler.registerModuleIds(['er/controller'], createFile('er/controller'));120 var moduleId = 'er';121 expect(compiler.toPackage(moduleId)).to.eql(122 'define(\'er/controller\', [], function () {\n return \'er/controller\';\n});'123 + '\n\n'124 + 'define(\'er/locator\', [], function () {\n return \'er/locator\';\n});'125 + '\n\n'126 + 'define(\'er/URL\', [], function () {\n return \'er/URL\';\n});'127 + '\n\n'128 + 'define(\'er/Action\', [\n \'eoo\',\n \'underscore\'\n], function () {\n return \'er/Action\';\n});'129 + '\n\n'130 + 'define(\'er/View\', [], function () {\n return \'er/View\';\n});'131 + '\n\n'132 + 'define(\'er/main\', [], function () {\n return \'er\';\n});'133 + '\n\n'134 + 'define(\'er\', [\'er/main\'], function (main) { return main; });');135 });136 it('toBundle', function () {137 var moduleConfig = {138 packages: [139 {140 name: 'er',141 location: '../dep/er/0.0.0/src'142 }143 ],144 combine: {145 app: true146 }147 };148 var compiler = new Compiler(moduleConfig);149 compiler.registerModuleIds(['app'], createFile('app', ['./lib', 'er']));150 compiler.registerModuleIds(['lib'], createFile('lib', ['js!./x.js', 'css!./x.css', 'er']));151 compiler.registerModuleIds(['js'], createFile('js'));152 compiler.registerModuleIds(['css'], createFile('css'));153 compiler.registerModuleIds(['er', 'er/main'], createFile('er'));154 var moduleId = 'app';155 expect(compiler.toBundle(moduleId)).to.eql(156 'define(\'js\', [], function () {\n return \'js\';\n});'157 + '\n\n'158 + 'define(\'css\', [], function () {\n return \'css\';\n});'159 + '\n\n'160 + 'define(\'er/main\', [], function () {\n return \'er\';\n});'161 + '\n\n'162 + 'define(\'er\', [\'er/main\'], function (main) { return main; });'163 + '\n\n'164 + 'define(\'lib\', [\n \'js!./x.js\',\n \'css!./x.css\',\n \'er\'\n], function () {\n return \'lib\';\n});'165 + '\n\n'166 + 'define(\'app\', [\n \'./lib\',\n \'er\'\n], function () {\n return \'app\';\n});');167 });168 it('case-xtpl', function () {169 var moduleConfig = {170 baseUrl: 'src',171 paths: {172 hello: 'bar/hello',173 css: 'resource/css',174 xtpl: 'common/xtpl',175 xtpl2: 'common/xtpl',176 xtpl3: 'common/xtpl',177 ztpl: 'common/ztpl',178 ztpl2: 'common/ztpl'179 },180 combine: {181 'case-xtpl': true182 }183 };184 var compiler = new Compiler(moduleConfig);185 compiler.registerModuleIds(['case-xtpl'], createFile('case-xtpl', ['xtpl', 'common/xtpl']));186 compiler.registerModuleIds(['xtpl', 'xtpl2', 'xtpl3', 'common/xtpl'], createFile('xtpl'));187 var moduleId = 'case-xtpl';188 expect(compiler.toBundle(moduleId)).to.eql(189 'define(\'xtpl\', [], function () {\n return \'xtpl\';\n});'190 + '\n\n\n'191 + '/** d e f i n e */\ndefine(\'xtpl2\', [\'xtpl\'], function (target) { return target; });'192 + '\n\n\n'193 + '/** d e f i n e */\ndefine(\'xtpl3\', [\'xtpl\'], function (target) { return target; });'194 + '\n\n\n'195 + '/** d e f i n e */\ndefine(\'common/xtpl\', [\'xtpl\'], function (target) { return target; });'196 + '\n\n'197 + 'define(\'case-xtpl\', [\n \'xtpl\',\n \'common/xtpl\'\n], function () {\n return \'case-xtpl\';\n});');198 });199 it('ssp promise duplicate issue', function () {200 var moduleConfig = {201 baseUrl: 'src',202 combine: {203 'ssp/bar': 1,204 'ssp/foo': {205 files: [206 '!ssp/promise'207 ]208 }209 }210 };211 var compiler = new Compiler(moduleConfig);212 compiler.registerModuleIds(['ssp/bar'], createFile('ssp/bar', ['./promise']));213 compiler.registerModuleIds(['ssp/foo'], createFile('ssp/foo', ['./bar']));214 compiler.registerModuleIds(['ssp/promise'], createFile('ssp/promise'));215 expect(compiler.toBundle('ssp/bar')).to.eql(216 'define(\'ssp/promise\', [], function () {\n return \'ssp/promise\';\n});'217 + '\n\n'218 + 'define(\'ssp/bar\', [\'./promise\'], function () {\n return \'ssp/bar\';\n});');219 expect(compiler.toBundle('ssp/foo')).to.eql(220 'define(\'ssp/bar\', [\'./promise\'], function () {\n return \'ssp/bar\';\n});'221 + '\n\n'222 + 'define(\'ssp/foo\', [\'./bar\'], function () {\n return \'ssp/foo\';\n});');223 expect(compiler.toBundle('ssp/bar')).to.eql(224 'define(\'ssp/promise\', [], function () {\n return \'ssp/promise\';\n});'225 + '\n\n'226 + 'define(\'ssp/bar\', [\'./promise\'], function () {\n return \'ssp/bar\';\n});');227 });228 it('toBundle (paths)', function () {229 var moduleConfig = {230 baseUrl: 'src',231 paths: {232 tpl: 'common/tpl',233 js: 'common/js'234 },235 combine: {236 app: true237 }238 };239 var compiler = new Compiler(moduleConfig);240 compiler.registerModuleIds(['app'], createFile('app', ['js!//www.baidu.com/relay.js', 'tpl!./a.tpl.html']));241 compiler.registerModuleIds(['js', 'common/js'], createFile('js'));242 compiler.registerModuleIds(['tpl', 'common/tpl'], createFile('tpl'));243 var moduleId = 'app';244 expect(compiler.toBundle(moduleId)).to.eql(245 'define(\'js\', [], function () {\n return \'js\';\n});'246 + '\n\n\n'247 + '/** d e f i n e */\ndefine(\'common/js\', [\'js\'], function (target) { return target; });'248 + '\n\n'249 + 'define(\'tpl\', [], function () {\n return \'tpl\';\n});'250 + '\n\n\n'251 + '/** d e f i n e */\ndefine(\'common/tpl\', [\'tpl\'], function (target) { return target; });'252 + '\n\n'253 + 'define(\'app\', [\n \'js!//www.baidu.com/relay.js\',\n \'tpl!./a.tpl.html\'\n], function () {\n return \'app\';\n});');254 });...
_prefill.js
Source:_prefill.js
...15 console.log(`Deleted ${deleted.length} files.`);16 })17 // all versions need these files to run properly18 {19 await createFile(config.assets + config.assetsSubpath + '/sass/app/app.scss',20 "/*" + "\n" +21 " assets/_src/sass/app/app.scss" + "\n" +22 "*/" + "\n" +23 "" + "\n" +24 "/*" + "\n" +25 " CHARSET" + "\n" +26 "*/" + "\n" +27 "" + "\n" +28 '@charset "UTF-8";' + "\n" +29 "" + "\n" +30 "/*" + "\n" +31 " IMPORTS" + "\n" +32 "*/" + "\n" +33 ""34 )35 await createFile('./_includes/app/global/head.html', '<!-- App Head Content -->');36 await createFile('./_includes/app/global/head-pre-bundle.html', '<!-- App Head Content (pre-bundle) -->');37 await createFile('./_includes/app/global/foot.html', '<!-- App Foot Content -->');38 await createFile('./_includes/app/global/foot-pre-bundle.html', '<!-- App Foot Content (pre-bundle) -->');39 await createFile(`./_includes/app/elements/header.html`, '<!-- App Header Content -->');40 await createFile(`./_includes/app/elements/footer.html`, '<!-- App Footer Content -->');41 await createFile('./_includes/app/misc/ads.txt', '');42 await createFile('./_includes/app/misc/budget.json', '');43 await createFile('./_includes/app/misc/manifest.json', '');44 await createFile('./_includes/app/misc/robots.txt', '');45 await createFile(config.assets + config.assetsSubpath + '/js/app/app.js',46 "Manager.ready(function() {" + "\n" +47 " Manager.log('app.js fired Manager.ready()');" + "\n" +48 "" + "\n" +49 " // Add additional logic here!" + "\n" +50 " // var theme = require('../theme/theme.js');" + "\n" +51 "" + "\n" +52 "});" + "\n" +53 ""54 )55 if (!fs.exists('./pages/index.md') && !fs.exists('./pages/index.html')) {56 await createFile('./pages/index.md',57 '---' + '\n' +58 '### ALL PAGES ###' + '\n' +59 'layout: master/global/default' + '\n' +60 'permalink: /' + '\n' +61 'sitemap:' + '\n' +62 ' include: false' + '\n' +63 '' + '\n' +64 '### REGULAR PAGES ###' + '\n' +65 'meta:' + '\n' +66 ' title: "Home"' + '\n' +67 ' description: "We are a great company and would love to design an intuitive solution for you!"' + '\n' +68 ' breadcrumb: "Home"' + '\n' +69 '---' + '\n' +70 'This is a wonderful homepage!' +71 ''72 )73 }74 await createFile(config.assets + config.assetsSubpath + '/js/app/service-worker.js',75 "// app service-worker.js code" + "\n" +76 "if (typeof log === 'undefined') {" + "\n" +77 " var log = function() {};" + "\n" +78 "}" + "\n" +79 "log('app service-worker.js loaded: ', self.location.pathname);" + "\n" +80 "" + "\n" +81 "// Note: any importScripts(); are relative to the master-service-worker.js location" + "\n" +82 "// importScripts('../../app/service-worker.js');" + "\n" +83 ''84 )85 await createFile('_websrc/gulp_tasks/app/main.js',86 "const gulp = require('gulp');" + "\n" +87 "const newer = require('gulp-newer');" + "\n" +88 "const through = require('through2');" + "\n" +89 "const argv = require('yargs').argv;" + "\n" +90 "const fetch = require('node-fetch');" + "\n" +91 "const tools = new (require('../../libraries/tools.js'));" + "\n" +92 "" + "\n" +93 "gulp.task('sample', function() {" + "\n" +94 " // write your first task here!" + "\n" +95 " // then set up 'watch' tasks in the app.config.js" + "\n" +96 "});" + "\n" +97 ""98 )99 // post100 // const posts = await listFiles('./_posts') || [];101 // if (posts.find(function (name) {102 // return name.indexOf('example-post') > -1;103 // })) {104 if ((await listFiles('./_posts') || []).length < 2) {105 for (var i = 1; i < 8; i++) {106 await createFile(`./_posts/2019-01-0${i}-example-post-${i}.md`,107 '---' + '\n' +108 '### ALL PAGES ###' + '\n' +109 'layout: master/blog/post' + '\n' +110 '' + '\n' +111 '### POST ONLY ###' + '\n' +112 'post:' + '\n' +113 ` title: Example post number ${i}` + '\n' +114 // ` date: 2019-01-0${i}` + '\n' +115 ` excerpt: This is a sample excerpt for post number ${i}` + '\n' +116 ` description: This is a sample excerpt for post number ${i}` + '\n' +117 ` author: samantha` + '\n' +118 ` id: ${i}` + '\n' +119 ` tags: [tag, tag2, tag3]` + '\n' +120 ` categories: [marketing, business]` + '\n' +121 ` affiliate-search-term: Marketing` + '\n' +122 '---' + '\n' +123 '' + '\n' +124 `## Title inside post ${i}` + '\n' +125 'This is a wonderful paragrah inside a post!' + '\n' +126 ''127 )128 }129 }130 // await createFile(`blog/index.html`,131 // '---' + '\n' +132 // '### ALL PAGES ###' + '\n' +133 // 'layout: master/blog/index' + '\n' +134 // '---' + '\n'135 // );136 //137 // await createFile(`./blog/authors/index.html`,138 // '---' + '\n' +139 // '### ALL PAGES ###' + '\n' +140 // 'layout: master/authors/index' + '\n' +141 // '---' + '\n'142 // );143 await createFile(`./_authors/samantha.md`, await readFile('./_websrc/templates/master/authors/example-author.md'));144 await createFile(`./_websrc/unit_tests/app/test.js`, await readFile('./_websrc/templates/master/tests/test.js'));145 await fs.writeAsync(`./_websrc/generated/common-modules.scss`, generateCommonModules());146 // Create directories that get deleted through git147 fs.dir(`./_includes/app/assets`);148 fs.dir(`./_includes/app/elements`);149 fs.dir(`./_includes/app/global`);150 fs.dir(`./_includes/app/helpers`);151 fs.dir(`./_includes/app/helpers`);152 fs.dir(`./_includes/app/misc`);153 fs.dir(`./_includes/app/modules`);154 fs.dir(`./_layouts/app/blog`);155 fs.dir(`./_layouts/app/global`);156 fs.dir(`./_websrc/templates/app`);157 fs.dir(`./assets/_src/images/favicon`);158 fs.dir(`./assets/_src/images/og`);159 fs.dir(`./assets/_src/sass/theme`);160 fs.dir(`./assets/_src/js/theme`);161 fs.dir(`./assets/_src-uncompiled`);162 fs.dir(`./special/app/feeds`);163 fs.dir(`./special/app/misc`);164 fs.dir(`./special/app/pages`);165 fs.dir(`./special/app/search`);166 fs.dir('./@output/lighthouse');167 fs.remove('./@output/build/build.json');168 await createFile('./@output/build/build.json', build_json);169 // Create the master service worker170 await fs.writeAsync('./special/master/misc/master-service-worker.js',171 (await readFile('./_websrc/templates/master/js/master-service-worker.js')).replace(/{firebase-version}/img,172 require('web-manager/package.json').dependencies.firebase.replace(/\^|~/img, '')173 )174 );175 }176 // only create these files if NOT on template177 if (!tools.isTemplate) {178 }179 // only create these files if IS ON template and IS NOT server180 if (tools.isTemplate && !tools.isServer) {181 await createFile(config.assets + config.assetsSubpath + '/sass/app/.gitignore', gitignore_ph);182 await createFile(config.assets + config.assetsSubpath + '/js/app/.gitignore', gitignore_ph);183 await createFile(config.assets + config.assetsSubpath + '/images/blog/.gitignore', gitignore_ph);184 await createFile('./_includes/app/misc/.gitignore', gitignore_ph);185 await createFile('./_includes/app/global/.gitignore', gitignore_ph);186 await createFile('./_websrc/gulp_tasks/app/.gitignore', gitignore_ph);187 await createFile('./pages/.gitignore', '/index.md'+'\n'+'.gitignore'+'\n');188 await createFile('./blog/.gitignore', '/index.html'+'\n'+'.gitignore'+'\n');189 // POST190 await createFile('./_posts/.gitignore', gitignore_ph);191 await createFile('./_authors/.gitignore', gitignore_ph);192 }193 // Only for non-server environment194 if (!tools.isServer) {195 await createFile('./@output/build/.gitignore', gitignore_ph);196 await createFile('./special/master/misc/.gitignore', '/master-service-worker.js'+'\n'+'.gitignore'+'\n');197 } else {198 await createFile('./CNAME', new URL(_configYml.url).host);199 }200 Global.set('prefillStatus', 'done');201 return resolve();202 } catch (e) {203 return reject(e)204 }205 });206});207function generateCommonModules() {208 let contents = '';209 if (fs.exists('./node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss')) {210 contents += `211 $fa-font-path: '../webfonts';212 $fa-font-display: swap;213 @import 'node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss';214 @import 'node_modules/@fortawesome/fontawesome-free/scss/solid.scss';215 `216 }217 return contents;218}219async function createFile(file, contents) {220 var response = {221 exists: false,222 error: null,223 }224 return new Promise(function(resolve, reject) {225 try {226 if (fs.exists(file)) {227 response.exists = true;228 resolve(response)229 } else {230 fs.write(file, contents);231 response.exists = false;232 resolve(response);233 }...
Code.gs
Source:Code.gs
...43 }44 }45 if(flag == 0){46 var new_folder = destination.createFolder("SSR20-21- 0" + gno).getId();47 var createFile1 = DriveApp.getFolderById(new_folder).createFile(f1).setName("SSR20-21- 0"+gno+" -Video")48 var createFile2 = DriveApp.getFolderById(new_folder).createFile(f2).setName("SSR20-21- 0"+gno+" -Social media/New paper cuttings")49 var createFile3 = DriveApp.getFolderById(new_folder).createFile(f3).setName("SSR20-21- 0"+gno+" -PPT presentation")50 var createFile4 = DriveApp.getFolderById(new_folder).createFile(f4).setName("SSR20-21- 0"+gno+" -ProjectReport")51 var createFile5 = DriveApp.getFolderById(new_folder).createFile(f5).setName("SSR20-21- 0"+gno+" -A3poster")52 var createFile6 = DriveApp.getFolderById(new_folder).createFile(f6).setName("SSR20-21- 0"+gno+" -FileContainingSurveys/images/etc")53 var createFile7 = DriveApp.getFolderById(new_folder).createFile(f7).setName("SSR20-21- 0"+gno+" -Blog(MSWord)")54 return true;55 }56 else57 return false58 }59 else if(mentor == "B")60 {61 var destination = DriveApp.getFolderById(indira)62 var contents = destination.getFolders()63 var flag = 064 while(contents.hasNext()) {65 file = contents.next();66 name = file.getName();67 tmp = "SSR20-21- 0" + gno68 if(name == tmp){69 flag = 170 71 }72 }73 if(flag == 0){74 var new_folder = destination.createFolder("SSR20-21- 0" + gno).getId();75 var createFile1 = DriveApp.getFolderById(new_folder).createFile(f1).setName("SSR20-21- 0"+gno+" -Video")76 var createFile2 = DriveApp.getFolderById(new_folder).createFile(f2).setName("SSR20-21- 0"+gno+" -Social media/New paper cuttings")77 var createFile3 = DriveApp.getFolderById(new_folder).createFile(f3).setName("SSR20-21- 0"+gno+" -PPT presentation")78 var createFile4 = DriveApp.getFolderById(new_folder).createFile(f4).setName("SSR20-21- 0"+gno+" -ProjectReport")79 var createFile5 = DriveApp.getFolderById(new_folder).createFile(f5).setName("SSR20-21- 0"+gno+" -A3poster")80 var createFile6 = DriveApp.getFolderById(new_folder).createFile(f6).setName("SSR20-21- 0"+gno+" -FileContainingSurveys/images/etc")81 var createFile7 = DriveApp.getFolderById(new_folder).createFile(f7).setName("SSR20-21- 0"+gno+" -Blog(MSWord)")82 return true83 }84 else85 return false86 }87 else if(mentor == "C")88 {89 var destination = DriveApp.getFolderById(narayanan)90 var contents = destination.getFolders()91 var flag = 092 while(contents.hasNext()) {93 file = contents.next();94 name = file.getName();95 tmp = "SSR20-21- 0" + gno96 if(name == tmp){97 flag = 198 99 }100 }101 if(flag == 0){102 var new_folder = destination.createFolder("SSR20-21- 0" + gno).getId();103 var createFile1 = DriveApp.getFolderById(new_folder).createFile(f1).setName("SSR20-21- 0"+gno+" -Video")104 var createFile2 = DriveApp.getFolderById(new_folder).createFile(f2).setName("SSR20-21- 0"+gno+" -Social media/New paper cuttings")105 var createFile3 = DriveApp.getFolderById(new_folder).createFile(f3).setName("SSR20-21- 0"+gno+" -PPT presentation")106 var createFile4 = DriveApp.getFolderById(new_folder).createFile(f4).setName("SSR20-21- 0"+gno+" -ProjectReport")107 var createFile5 = DriveApp.getFolderById(new_folder).createFile(f5).setName("SSR20-21- 0"+gno+" -A3poster")108 var createFile6 = DriveApp.getFolderById(new_folder).createFile(f6).setName("SSR20-21- 0"+gno+" -FileContainingSurveys/images/etc")109 var createFile7 = DriveApp.getFolderById(new_folder).createFile(f7).setName("SSR20-21- 0"+gno+" -Blog(MSWord)")110 e={'parameter':{'page':'lastPage'}}111 // doGet(e)112 return true;113 }114 else115 return false;116 117 }118 119 return false;120}121function homePageCall(){122 flag = 2123 // return HtmlService.createHtmlOutputFromFile("homePage.html")...
close_async.tentative.https.any.js
Source:close_async.tentative.https.any.js
...4// META: timeout=long5'use strict';6promise_test(async testCase => {7 await reserveAndCleanupCapacity(testCase);8 const file = await createFile(testCase, 'file_name');9 assert_equals(await file.close(), undefined);10 assert_equals(await file.close(), undefined);11}, 'NativeIOFile.close is idempotent');12promise_test(async testCase => {13 await reserveAndCleanupCapacity(testCase);14 const file = await createFile(testCase, 'file_name');15 const closePromise = file.close();16 assert_equals(await file.close(), undefined);17 assert_equals(await closePromise, undefined);18}, 'NativeIOFile.close is idempotent when called immediately');19promise_test(async testCase => {20 await reserveAndCleanupCapacity(testCase);21 const file = await createFile(testCase, 'file_name');22 assert_equals(await file.close(), undefined);23 const readBuffer = new Uint8Array(4);24 await promise_rejects_dom(testCase, 'InvalidStateError',25 file.read(readBuffer, 4));26}, 'NativeIOFile.read fails after NativeIOFile.close settles');27promise_test(async testCase => {28 await reserveAndCleanupCapacity(testCase);29 const file = await createFile(testCase, 'file_name');30 const closePromise = file.close();31 const readBuffer = new Uint8Array(4);32 await promise_rejects_dom(testCase, 'InvalidStateError',33 file.read(readBuffer, 4));34 assert_equals(await closePromise, undefined);35}, 'NativeIOFile.read fails immediately after calling NativeIOFile.close');36promise_test(async testCase => {37 await reserveAndCleanupCapacity(testCase);38 const file = await createFile(testCase, 'file_name');39 assert_equals(await file.close(), undefined);40 const writeBuffer = new Uint8Array(4);41 writeBuffer.set([96, 97, 98, 99]);42 await promise_rejects_dom(testCase, 'InvalidStateError',43 file.write(writeBuffer, 4));44}, 'NativeIOFile.write fails after NativeIOFile.close settles');45promise_test(async testCase => {46 await reserveAndCleanupCapacity(testCase);47 const file = await createFile(testCase, 'file_name');48 const closePromise = file.close();49 const writeBuffer = new Uint8Array(4);50 writeBuffer.set([96, 97, 98, 99]);51 await promise_rejects_dom(testCase, 'InvalidStateError',52 file.write(writeBuffer, 4));53 assert_equals(await closePromise, undefined);54}, 'NativeIOFile.write fails immediately after calling NativeIOFile.close');55promise_test(async testCase => {56 await reserveAndCleanupCapacity(testCase);57 const file = await createFile(testCase, 'file_name');58 assert_equals(await file.close(), undefined);59 await promise_rejects_dom(testCase, 'InvalidStateError', file.getLength());60}, 'NativeIOFile.getLength fails after NativeIOFile.close settles');61promise_test(async testCase => {62 await reserveAndCleanupCapacity(testCase);63 const file = await createFile(testCase, 'file_name');64 const closePromise = file.close();65 await promise_rejects_dom(testCase, 'InvalidStateError', file.getLength());66 assert_equals(await closePromise, undefined);67}, 'NativeIOFile.getLength fails immediately after calling NativeIOFile.close');68promise_test(async testCase => {69 await reserveAndCleanupCapacity(testCase);70 const file = await createFile(testCase, 'file_name');71 assert_equals(await file.close(), undefined);72 await promise_rejects_dom(testCase, 'InvalidStateError', file.flush());73}, 'NativeIOFile.flush fails after NativeIOFile.close settles');74promise_test(async testCase => {75 await reserveAndCleanupCapacity(testCase);76 const file = await createFile(testCase, 'file_name');77 const closePromise = file.close();78 await promise_rejects_dom(testCase, 'InvalidStateError', file.flush());79 assert_equals(await closePromise, undefined);80}, 'NativeIOFile.flush fails immediately after calling NativeIOFile.close');81promise_test(async testCase => {82 await reserveAndCleanupCapacity(testCase);83 const file = await createFile(testCase, 'file_name');84 assert_equals(await file.close(), undefined);85 await promise_rejects_dom(testCase, 'InvalidStateError', file.setLength(5));86}, 'NativeIOFile.setLength fails after NativeIOFile.close settles');87promise_test(async testCase => {88 await reserveAndCleanupCapacity(testCase);89 const file = await createFile(testCase, 'file_name');90 const closePromise = file.close();91 await promise_rejects_dom(testCase, 'InvalidStateError', file.setLength(5));92 assert_equals(await closePromise, undefined);...
zippedBoilerPlate.js
Source:zippedBoilerPlate.js
1const zippedBoilerPlate = require('express').Router();2const { models: { Code }} = require('../db')3const ejs = require('ejs')4const nodezip = require('node-zip')5async function createFile(key, variable){ 6 try{7 let data = await Code.findByPk(key)8 let name = data.fileName9 let contents = ejs.render(data.snippet, variable)10 return {name, contents}11 }catch(er){12 console.log(er)13 }14}15zippedBoilerPlate.post('/', async (req, res, next) => {16 try {17 let zip = new nodezip();18 async function zipHelper(fileString, arrObject){ 19 if (arrObject.length){20 arrObject.forEach(file => zip.file(`${fileString}${file.name}`, file.contents))21 }22 }23 let boiler = req.body24 //need to fix the issues here with wrong datatypes being passed through for whatever reason25 let appjsObjectArray = []26 //intialize variables27 let reactreduxObjectArray = [] 28 let clientObjectArray = []29 let publicObjectArray = []30 let modelObjectArray = []31 let dbObjectArray = []32 let routesObjectArray = []33 let serverObjectArray = []34 let configObjectArray = []35 36 //react 37 if(boiler.react){38 appjsObjectArray.push(createFile('R2', boiler))39 configObjectArray.push(createFile('S10',{}))40 configObjectArray.push(createFile('R7', boiler))41 clientObjectArray.push(createFile('R1', boiler))42 //react redux logic43 if(boiler.react.redux){44 //creates array object for redux components on client side45 reactreduxObjectArray.push(createFile('R3', {}))46 reactreduxObjectArray.push(createFile('R4', {}))47 reactreduxObjectArray.push(createFile('R5', {}))48 reactreduxObjectArray.push(createFile('R6', {}))49 }50 //add react hooks component51 if(boiler.react.reacthooks){52 appjsObjectArray.push(createFile('R8', {}))53 }54 }55 56 //The app index html creation for htmlindex in public folder57 clientObjectArray.push(createFile('P1', boiler))58 //CSS file creation in public folder59 publicObjectArray.push(createFile('P2', {}))60 if(boiler.server){61 configObjectArray.push(createFile('S9', boiler))62 serverObjectArray.push(createFile('S2', boiler))63 serverObjectArray.push(createFile('S1', boiler))64 routesObjectArray.push(createFile('S8', boiler))65 66 if(boiler.server.db){67 //main db file creation68 dbObjectArray.push(createFile('S3', {}))69 //seeding file created70 configObjectArray.push(createFile('S7', {}))71 //server database object creation72 modelObjectArray.push(createFile('S4', {}))73 modelObjectArray.push(createFile('S6', {}))74 modelObjectArray.push(createFile('S5', {}))75 //extra router file creation76 if(boiler.server.db.extraRouter){77 routesObjectArray.push(createFile('S11', {}))78 }79 }80 }81 82 await Promise.all(reactreduxObjectArray).then((data)=>zipHelper('client/reactredux/', data))83 await Promise.all(clientObjectArray).then((data)=>zipHelper('client/', data))84 await Promise.all(publicObjectArray).then((data)=>zipHelper('public/', data))85 await Promise.all(modelObjectArray).then((data)=>zipHelper('server/db/models/', data))86 await Promise.all(dbObjectArray).then((data)=>zipHelper('server/db/', data))87 await Promise.all(routesObjectArray).then((data)=>zipHelper('server/routes/', data))88 await Promise.all(serverObjectArray).then((data)=>zipHelper('server/', data))89 await Promise.all(appjsObjectArray).then((data)=>zipHelper('client/components/', data))90 await Promise.all(configObjectArray).then((data)=>zipHelper('', data)).then(()=>{91 ...
module.spec.js
Source:module.spec.js
...5var expect = require('expect.js');6var Module = require('../src/module');7var Compiler = require('../src/compiler');8describe('Module', function () {9 function createFile(moduleId, deps) {10 var contents = deps11 ? new Buffer('define(' + JSON.stringify(deps) + ', function () { return "' + moduleId + '"});')12 : new Buffer('define(function () { return "' + moduleId + '"});');13 return {14 contents: contents15 };16 }17 it('default', function () {18 var moduleConfig = {};19 var compiler = new Compiler(moduleConfig);20 compiler.registerModuleIds(['er', 'er/main'], createFile('er'));21 compiler.registerModuleIds(['er/View'], createFile('er/View'));22 compiler.registerModuleIds(['er/controller'], createFile('er/controller'));23 compiler.registerModuleIds(['app'], createFile('app'));24 var app = new Module('app', compiler);25 expect(app.toBundle()).to.eql('define(\'app\', [], function () {\n return \'app\';\n});');26 });27 it('explict include is supported', function () {28 var moduleConfig = {29 combine: {30 app: {31 files: [32 '!er/**',33 'er/main',34 'er/View'35 ]36 }37 }38 };39 var compiler = new Compiler(moduleConfig);40 compiler.registerModuleIds(['er/main'], createFile('er/main'));41 compiler.registerModuleIds(['er/View'], createFile('er/View'));42 compiler.registerModuleIds(['er/controller'], createFile('er/controller'));43 compiler.registerModuleIds(['app'], createFile('app'));44 var app = new Module('app', compiler);45 expect(app.toBundle()).to.eql(46 'define(\'er/View\', [], function () {\n return \'er/View\';\n});'47 + '\n\n'48 + 'define(\'er/main\', [], function () {\n return \'er/main\';\n});'49 + '\n\n'50 + 'define(\'app\', [], function () {\n return \'app\';\n});');51 });52 it('explict exclude is supported', function () {53 var moduleConfig = {54 baseUrl: 'src',55 packages: [56 {57 name: 'er',58 location: '../dep/er/src',59 main: 'main.js'60 }61 ],62 combine: {63 app: {64 files: [65 '!er/**',66 'er/main'67 ]68 }69 }70 };71 var compiler = new Compiler(moduleConfig);72 compiler.registerModuleIds(['er', 'er/main'], createFile('er'));73 compiler.registerModuleIds(['er/View'], createFile('er/View'));74 compiler.registerModuleIds(['er/controller'], createFile('er/controller'));75 compiler.registerModuleIds(['app'], createFile('app', ['er', 'er/View']));76 var app = new Module('app', compiler);77 expect(app.toBundle()).to.eql(78 'define(\'er/main\', [], function () {\n return \'er\';\n});'79 + '\n\n'80 + 'define(\'er\', [\'er/main\'], function (main) { return main; });'81 + '\n\n'82 + 'define(\'app\', [\n \'er\',\n \'er/View\'\n], function () {\n return \'app\';\n});'83 );84 });...
makeFeature.js
Source:makeFeature.js
...16 .createDirectory(`/features/${envCamelCase}/redux/connectors`)17 .createDirectory(`/features/${envCamelCase}/redux/__tests__`)18 // Model19 .createDirectory(`/features/${envCamelCase}/models`)20 .createFile(`/features/${envCamelCase}/models/${Case.pascal(env)}.js`, Files.Model(env))21 // File22 .createFile(`/features/${envCamelCase}/index.js`, `23export * from './components'24export * from './redux'`)25 .createFile(`/features/${envCamelCase}/components/index.js`, `26import ${envPascalCase}Container from './${envPascalCase}Container'27export { ${envPascalCase}Container }28`)29 .createFile(`/features/${envCamelCase}/components/styles.js`, Files.Style())30 .createFile(`/features/${envCamelCase}/components/${envPascalCase}Container.js`, Files.Component(`${envPascalCase}Container`))31 .createFile(`/features/${envCamelCase}/redux/index.js`, `32export * from './connectors'33export { ${envCamelCase}Reducer } from './${envCamelCase}Reducer'34export { ${envPascalCase}Selector } from './${envCamelCase}Selector'35`)36 .createFile(`/features/${envCamelCase}/redux/${envCamelCase}Actions.js`, Files.Actions(env))37 .createFile(`/features/${envCamelCase}/redux/${envCamelCase}ActionTypes.js`, Files.ActionTypes(env))38 .createFile(`/features/${envCamelCase}/redux/connectors/index.js`, `39export { with${envPascalCase}List } from './with${envPascalCase}List'40export { with${envPascalCase}Detail } from './with${envPascalCase}Detail'41`)42 .createFile(`/features/${envCamelCase}/redux/connectors/with${envPascalCase}List.js`, Files.ConnectorList(env, 'list'))43 .createFile(`/features/${envCamelCase}/redux/connectors/with${envPascalCase}Detail.js`, Files.ConnectorDetail(env, 'detail'))44 .createFile(`/features/${envCamelCase}/redux/${envCamelCase}Endpoints.js`, Files.Endpoints(env))45 .createFile(`/features/${envCamelCase}/redux/${envCamelCase}Reducer.js`, Files.Reducer(env))46 .createFile(`/features/${envCamelCase}/redux/${envCamelCase}Selector.js`, Files.Selector(env))47 .createFile(`/features/${envCamelCase}/redux/${envCamelCase}Utils.js`, '')48 // UnitTest49 .createFile(`/features/${envCamelCase}/redux/__tests__/${envCamelCase}Actions.spec.js`, Files.UnitTestActions(env))50 .createFile(`/features/${envCamelCase}/redux/__tests__/${envCamelCase}Reducer.spec.js`, Files.UnitTestReducer(env))51 .createFile(`/features/${envCamelCase}/redux/__tests__/${envCamelCase}Selector.spec.js`, Files.UnitTestSelector(env))52 log.default('\nPlease add text info file ./src/views/features/index.js\n');53 log.success(`export * from './${envCamelCase}'\n`);54};...
generateProject.js
Source:generateProject.js
2const fs = require('fs-extra')3const logger = require('../libs/logger')4const generateProject = projectPath => {5 console.log('')6 createFile('package.json', projectPath)7 createFile('tsconfig.json', projectPath)8 createFile('README.md', projectPath)9 createFile('_dot_babelrc', '.babelrc', projectPath)10 createFile('_dot_editorconfig', '.editorconfig', projectPath)11 createFile('_dot_env', '.env', projectPath)12 createFile('_dot_env_dot_dev', '.env.dev', projectPath)13 createFile('_dot_env_dot_test', '.env.test', projectPath)14 createFile('_dot_eslintrc_dot_js', '.eslintrc.js', projectPath)15 createFile('_dot_gitignore', '.gitignore', projectPath)16 createFile('_dot_lintstagedrc', '.lintstagedrc', projectPath)17 createFile('_dot_prettierrc', '.prettierrc', projectPath)18 createFile('_dot_stylelintrc_dot_json', '.stylelintrc.json', projectPath)19 createFolder('bin', projectPath)20 createFile('bin/dev.sh', projectPath)21 createFile('bin/prod.sh', projectPath)22 createFile('bin/test.sh', projectPath)23 createFolder('public', projectPath)24 createFile('public/favicon.ico', projectPath)25 createFile('public/index.dev.html', projectPath)26 createFile('public/index.prod.html', projectPath)27 createFolder('src', projectPath)28 createFolder('src/pages', projectPath)29 createFolder('src/pages/home', projectPath)30 createFile('src/index.tsx', projectPath)31}32const createFolder = (folder, p) => {33 fs.mkdirSync(path.resolve(p, folder))34}35const createFile = (source, target, p) => {36 const _target = p ? target : source37 const _p = p ? p : target38 const template = path.resolve(require.resolve('@automs/template'), '..')39 const f = path.resolve(template, 'init', source)40 if (fs.existsSync(f)) {41 const str = String(fs.readFileSync(f))42 fs.writeFileSync(path.resolve(_p, _target), str)43 logger.succeed('å建 ' + _target)44 }...
Using AI Code Generation
1const { createFile } = require("fast-check-monorepo");2const { createFile } = require("fast-check-monorepo");3const { createFile } = require("fast-check-monorepo");4createFile("test.txt", "Hello World");5const { createFile } = require("fast-check-monorepo");6createFile("test.txt", "Hello World");7createFile("test.txt", "Hello World");8const { createFile } = require("fast-check-monorepo");9createFile("test.txt", "Hello World");10const { createFile } = require("fast-check-monorepo");11createFile("test.txt", "Hello World");12createFile("test.txt", "Hello World");13createFile("test.txt", "Hello World");14const { createFile } = require("fast-check-monorepo");15createFile("test.txt", "Hello World");16createFile("test.txt", "Hello World");17const { createFile } = require("fast-check-monorepo");18createFile("
Using AI Code Generation
1const { createFile } = require('fast-check-monorepo');2console.log(createFile());3const { createFile } = require('fast-check-monorepo/lib/createFile');4console.log(createFile());5const { createFile } = require('fast-check-monorepo/dist/createFile');6console.log(createFile());7const { createFile } = require('fast-check-monorepo/dist/lib/createFile');8console.log(createFile());9const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');10console.log(createFile());11const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');12console.log(createFile());13const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');14console.log(createFile());15const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');16console.log(createFile());17const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');18console.log(createFile());19const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');20console.log(createFile());21const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');22console.log(createFile());23const { createFile } = require('fast-check-monorepo/dist/lib/createFile.js');24console.log(createFile());
Using AI Code Generation
1const { createFile } = require('fast-check-monorepo');2createFile('foo.txt', 'bar');3const { createFile } = require('fast-check-monorepo');4createFile('foo2.txt', 'bar');5const { createFile } = require('fast-check-monorepo');6createFile('foo3.txt', 'bar');7const { createFile } = require('fast-check-monorepo');8createFile('foo4.txt', 'bar');9const { createFile } = require('fast-check-monorepo');10createFile('foo5.txt', 'bar');11const { createFile } = require('fast-check-monorepo');12createFile('foo6.txt', 'bar');13const { createFile } = require('fast-check-monorepo');14createFile('foo7.txt', 'bar');15const { createFile } = require('fast-check-monorepo');16createFile('foo8.txt', 'bar');17const { createFile } = require('fast-check-monorepo');18createFile('foo9.txt', 'bar');19const { createFile } = require('fast-check-monorepo');20createFile('foo10.txt', 'bar');21const { createFile } = require('fast-check-monorepo');22createFile('foo11.txt', 'bar');23const { createFile
Using AI Code Generation
1const fc = require('fast-check');2fc.createFile('test.txt', 'hello world');3const fc = require('fast-check');4fc.createFile('test.txt', 'hello world');5const fc = require('fast-check');6fc.createFile('test.txt', 'hello world');7const fc = require('fast-check');8fc.createFile('test.txt', 'hello world');9const fc = require('fast-check');10fc.createFile('test.txt', 'hello world');11const fc = require('fast-check');12fc.createFile('test.txt', 'hello world');13const fc = require('fast-check');14fc.createFile('test.txt', 'hello world');15const fc = require('fast-check');16fc.createFile('test.txt', 'hello world');17const fc = require('fast-check');18fc.createFile('test.txt', 'hello world');19const fc = require('fast-check');20fc.createFile('test.txt', 'hello world');21const fc = require('fast-check');22fc.createFile('test.txt', 'hello world');23const fc = require('fast-check');24fc.createFile('test.txt', 'hello world');25const fc = require('fast-check');26fc.createFile('test.txt', 'hello world
Using AI Code Generation
1import { createFile } from 'fast-check-monorepo';2createFile('test.txt', 'This is a test file');3import { createFile } from 'fast-check-monorepo';4createFile('test.txt', 'This is a test file');5import { createFile } from 'fast-check-monorepo';6createFile('test.txt', 'This is a test file');7import { createFile } from 'fast-check-monorepo';8createFile('test.txt', 'This is a test file');9import { createFile } from 'fast-check-monorepo';10createFile('test.txt', 'This is a test file');11import { createFile } from 'fast-check-monorepo';12createFile('test.txt', 'This is a test file');13import { createFile } from 'fast-check-monorepo';14createFile('test.txt', 'This is a test file');15import { createFile } from 'fast-check-monorepo';16createFile('test.txt', 'This is a test file');17import { createFile } from 'fast-check-monorepo';18createFile('test.txt', 'This is a test file');19import { createFile } from 'fast-check-monorepo';20createFile('test.txt', 'This is a test file');21import { createFile } from 'fast-check-monorepo';22createFile('test.txt', 'This is a test file');
Using AI Code Generation
1const createFile = require('fast-check-monorepo/src/createFile');2const filename = 'test.txt';3const content = 'Hello World';4createFile(filename, content);5const createFile = require('fast-check-monorepo/createFile');6const filename = 'test.txt';7const content = 'Hello World';8createFile(filename, content);9const createFile = require('fast-check-monorepo/createFile');10const filename = 'test.txt';11const content = 'Hello World';12createFile(filename, content);13If we want to import a file
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!