Best JavaScript code snippet using ava
test.js
Source:test.js
...23 }24 fs.rmdirSync(tmp);25});26test("glob - async", async (t) => {27 t.deepEqual((await globby("*.tmp")).sort(), [28 "a.tmp",29 "b.tmp",30 "c.tmp",31 "d.tmp",32 "e.tmp",33 ]);34});35test("glob - async - multiple file paths", (t) => {36 t.deepEqual(globby.sync(["a.tmp", "b.tmp"]), ["a.tmp", "b.tmp"]);37});38test("glob with multiple patterns - async", async (t) => {39 t.deepEqual(await globby(["a.tmp", "*.tmp", "!{c,d,e}.tmp"]), [40 "a.tmp",41 "b.tmp",42 ]);43});44test("respect patterns order - async", async (t) => {45 t.deepEqual(await globby(["!*.tmp", "a.tmp"]), ["a.tmp"]);46});47test("respect patterns order - sync", (t) => {48 t.deepEqual(globby.sync(["!*.tmp", "a.tmp"]), ["a.tmp"]);49});50test("glob - sync", (t) => {51 t.deepEqual(globby.sync("*.tmp"), [52 "a.tmp",53 "b.tmp",54 "c.tmp",55 "d.tmp",56 "e.tmp",57 ]);58 t.deepEqual(globby.sync(["a.tmp", "*.tmp", "!{c,d,e}.tmp"]), [59 "a.tmp",60 "b.tmp",61 ]);62 t.deepEqual(globby.sync(["!*.tmp", "a.tmp"]), ["a.tmp"]);63});64test("glob - sync - multiple file paths", (t) => {65 t.deepEqual(globby.sync(["a.tmp", "b.tmp"]), ["a.tmp", "b.tmp"]);66});67test("return [] for all negative patterns - sync", (t) => {68 t.deepEqual(globby.sync(["!a.tmp", "!b.tmp"]), []);69});70test("return [] for all negative patterns - async", async (t) => {71 t.deepEqual(await globby(["!a.tmp", "!b.tmp"]), []);72});73test("glob - stream", async (t) => {74 t.deepEqual((await getStream.array(globby.stream("*.tmp"))).sort(), [75 "a.tmp",76 "b.tmp",77 "c.tmp",78 "d.tmp",79 "e.tmp",80 ]);81});82test("glob - stream async iterator support", async (t) => {83 const results = [];84 for await (const path of globby.stream("*.tmp")) {85 results.push(path);86 }87 t.deepEqual(results, ["a.tmp", "b.tmp", "c.tmp", "d.tmp", "e.tmp"]);88});89test("glob - stream - multiple file paths", async (t) => {90 t.deepEqual(await getStream.array(globby.stream(["a.tmp", "b.tmp"])), [91 "a.tmp",92 "b.tmp",93 ]);94});95test("glob with multiple patterns - stream", async (t) => {96 t.deepEqual(97 await getStream.array(globby.stream(["a.tmp", "*.tmp", "!{c,d,e}.tmp"])),98 ["a.tmp", "b.tmp"]99 );100});101test("respect patterns order - stream", async (t) => {102 t.deepEqual(await getStream.array(globby.stream(["!*.tmp", "a.tmp"])), [103 "a.tmp",104 ]);105});106test("return [] for all negative patterns - stream", async (t) => {107 t.deepEqual(await getStream.array(globby.stream(["!a.tmp", "!b.tmp"])), []);108});109test("cwd option", (t) => {110 process.chdir(tmp);111 t.deepEqual(globby.sync("*.tmp", { cwd }), [112 "a.tmp",113 "b.tmp",114 "c.tmp",115 "d.tmp",116 "e.tmp",117 ]);118 t.deepEqual(globby.sync(["a.tmp", "*.tmp", "!{c,d,e}.tmp"], { cwd }), [119 "a.tmp",120 "b.tmp",121 ]);122 process.chdir(cwd);123});124test("don't mutate the options object - async", async (t) => {125 await globby(126 ["*.tmp", "!b.tmp"],127 Object.freeze({ ignore: Object.freeze([]) })128 );129 t.pass();130});131test("don't mutate the options object - sync", (t) => {132 globby.sync(133 ["*.tmp", "!b.tmp"],134 Object.freeze({ ignore: Object.freeze([]) })135 );136 t.pass();137});138test("don't mutate the options object - stream", async (t) => {139 await getStream.array(140 globby.stream(141 ["*.tmp", "!b.tmp"],142 Object.freeze({ ignore: Object.freeze([]) })143 )144 );145 t.pass();146});147test("expose generateGlobTasks", (t) => {148 const tasks = globby.generateGlobTasks(["*.tmp", "!b.tmp"], {149 ignore: ["c.tmp"],150 });151 t.is(tasks.length, 1);152 t.is(tasks[0].pattern, "*.tmp");153 t.deepEqual(tasks[0].options.ignore, ["c.tmp", "b.tmp"]);154});155test("expose hasMagic", (t) => {156 t.true(globby.hasMagic("**"));157 t.true(globby.hasMagic(["**", "path1", "path2"]));158 t.false(globby.hasMagic(["path1", "path2"]));159});160test("expandDirectories option", (t) => {161 t.deepEqual(globby.sync(tmp), [162 "tmp/a.tmp",163 "tmp/b.tmp",164 "tmp/c.tmp",165 "tmp/d.tmp",166 "tmp/e.tmp",167 ]);168 t.deepEqual(globby.sync("**", { cwd: tmp }), [169 "a.tmp",170 "b.tmp",171 "c.tmp",172 "d.tmp",173 "e.tmp",174 ]);175 t.deepEqual(globby.sync(tmp, { expandDirectories: ["a*", "b*"] }), [176 "tmp/a.tmp",177 "tmp/b.tmp",178 ]);179 t.deepEqual(180 globby.sync(tmp, {181 expandDirectories: {182 files: ["a", "b"],183 extensions: ["tmp"],184 },185 }),186 ["tmp/a.tmp", "tmp/b.tmp"]187 );188 t.deepEqual(189 globby.sync(tmp, {190 expandDirectories: {191 files: ["a", "b"],192 extensions: ["tmp"],193 },194 ignore: ["**/b.tmp"],195 }),196 ["tmp/a.tmp"]197 );198});199test("expandDirectories:true and onlyFiles:true option", (t) => {200 t.deepEqual(globby.sync(tmp, { onlyFiles: true }), [201 "tmp/a.tmp",202 "tmp/b.tmp",203 "tmp/c.tmp",204 "tmp/d.tmp",205 "tmp/e.tmp",206 ]);207});208test.failing("expandDirectories:true and onlyFiles:false option", (t) => {209 // Node-glob('tmp/**') => ['tmp', 'tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']210 // Fast-glob('tmp/**') => ['tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']211 // See https://github.com/mrmlnc/fast-glob/issues/47212 t.deepEqual(globby.sync(tmp, { onlyFiles: false }), [213 "tmp",214 "tmp/a.tmp",215 "tmp/b.tmp",216 "tmp/c.tmp",217 "tmp/d.tmp",218 "tmp/e.tmp",219 ]);220});221test("expandDirectories and ignores option", (t) => {222 t.deepEqual(223 globby.sync("tmp", {224 ignore: ["tmp"],225 }),226 []227 );228 t.deepEqual(229 globby.sync("tmp/**", {230 expandDirectories: false,231 ignore: ["tmp"],232 }),233 ["tmp/a.tmp", "tmp/b.tmp", "tmp/c.tmp", "tmp/d.tmp", "tmp/e.tmp"]234 );235});236test.failing("relative paths and ignores option", (t) => {237 process.chdir(tmp);238 t.deepEqual(239 globby.sync("../tmp", {240 cwd: process.cwd(),241 ignore: ["tmp"],242 }),243 []244 );245 process.chdir(cwd);246});247// Rejected for being an invalid pattern248[249 {},250 [{}],251 true,252 [true],253 false,254 [false],255 null,256 [null],257 undefined,258 [undefined],259 NaN,260 [NaN],261 5,262 [5],263 function () {},264 [function () {}],265].forEach((value) => {266 const valueString = util.format(value);267 const message = "Patterns must be a string or an array of strings";268 test(`rejects the promise for invalid patterns input: ${valueString} - async`, async (t) => {269 await t.throwsAsync(globby(value), TypeError);270 await t.throwsAsync(globby(value), message);271 });272 test(`throws for invalid patterns input: ${valueString} - sync`, (t) => {273 t.throws(() => {274 globby.sync(value);275 }, TypeError);276 t.throws(() => {277 globby.sync(value);278 }, message);279 });280 test(`throws for invalid patterns input: ${valueString} - stream`, (t) => {281 t.throws(() => {282 globby.stream(value);283 }, TypeError);284 t.throws(() => {285 globby.stream(value);286 }, message);287 });288 test(`generateGlobTasks throws for invalid patterns input: ${valueString}`, (t) => {289 t.throws(() => {290 globby.generateGlobTasks(value);291 }, TypeError);292 t.throws(() => {293 globby.generateGlobTasks(value);294 }, message);295 });296});297test("gitignore option defaults to false - async", async (t) => {298 const actual = await globby("*", { onlyFiles: false });299 t.true(actual.includes("node_modules"));300});301test("gitignore option defaults to false - sync", (t) => {302 const actual = globby.sync("*", { onlyFiles: false });303 t.true(actual.includes("node_modules"));304});305test("gitignore option defaults to false - stream", async (t) => {306 const actual = await getStream.array(307 globby.stream("*", { onlyFiles: false })308 );309 t.true(actual.includes("node_modules"));310});311test("respects gitignore option true - async", async (t) => {312 const actual = await globby("*", { gitignore: true, onlyFiles: false });313 t.false(actual.includes("node_modules"));314});315test("respects gitignore option true - sync", (t) => {316 const actual = globby.sync("*", { gitignore: true, onlyFiles: false });317 t.false(actual.includes("node_modules"));318});319test("respects gitignore option true - stream", async (t) => {320 const actual = await getStream.array(321 globby.stream("*", { gitignore: true, onlyFiles: false })322 );323 t.false(actual.includes("node_modules"));324});325test("respects gitignore option false - async", async (t) => {326 const actual = await globby("*", { gitignore: false, onlyFiles: false });327 t.true(actual.includes("node_modules"));328});329test("respects gitignore option false - sync", (t) => {330 const actual = globby.sync("*", { gitignore: false, onlyFiles: false });331 t.true(actual.includes("node_modules"));332});333test("gitignore option with stats option", async (t) => {334 const result = await globby("*", { gitignore: true, stats: true });335 const actual = result.map((x) => x.path);336 t.false(actual.includes("node_modules"));337});338test("gitignore option with absolute option", async (t) => {339 const result = await globby("*", { gitignore: true, absolute: true });340 t.false(result.includes("node_modules"));341});342test("respects gitignore option false - stream", async (t) => {343 const actual = await getStream.array(344 globby.stream("*", { gitignore: false, onlyFiles: false })345 );346 t.true(actual.includes("node_modules"));347});348test("`{extension: false}` and `expandDirectories.extensions` option", (t) => {349 t.deepEqual(350 globby.sync("*", {351 cwd: tmp,352 extension: false,353 expandDirectories: {354 extensions: ["md", "tmp"],355 },356 }),357 ["a.tmp", "b.tmp", "c.tmp", "d.tmp", "e.tmp"]358 );359});360test("throws when specifying a file as cwd - async", async (t) => {361 const isFile = path.resolve("fixtures/gitignore/bar.js");362 await t.throwsAsync(363 globby(".", { cwd: isFile }),364 "The `cwd` option must be a path to a directory"365 );366 await t.throwsAsync(367 globby("*", { cwd: isFile }),368 "The `cwd` option must be a path to a directory"369 );370});371test("throws when specifying a file as cwd - sync", (t) => {372 const isFile = path.resolve("fixtures/gitignore/bar.js");373 t.throws(() => {374 globby.sync(".", { cwd: isFile });375 }, "The `cwd` option must be a path to a directory");376 t.throws(() => {377 globby.sync("*", { cwd: isFile });378 }, "The `cwd` option must be a path to a directory");379});380test("throws when specifying a file as cwd - stream", (t) => {381 const isFile = path.resolve("fixtures/gitignore/bar.js");382 t.throws(() => {383 globby.stream(".", { cwd: isFile });384 }, "The `cwd` option must be a path to a directory");385 t.throws(() => {386 globby.stream("*", { cwd: isFile });387 }, "The `cwd` option must be a path to a directory");388});389test("don't throw when specifying a non-existing cwd directory - async", async (t) => {390 const actual = await globby(".", { cwd: "/unknown" });391 t.is(actual.length, 0);392});393test("don't throw when specifying a non-existing cwd directory - sync", (t) => {394 const actual = globby.sync(".", { cwd: "/unknown" });395 t.is(actual.length, 0);...
index.d.ts
Source:index.d.ts
...13 @example14 ```15 import globby = require('globby');16 (async () => {17 const paths = await globby('images', {18 expandDirectories: {19 files: ['cat', 'unicorn', '*.jpg'],20 extensions: ['png']21 }22 });23 console.log(paths);24 //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']25 })();26 ```27 */28 readonly expandDirectories?: ExpandDirectoriesOption;29 /**30 Respect ignore patterns in `.gitignore` files that apply to the globbed files.31 @default false32 */33 readonly gitignore?: boolean;34 }35 interface GlobTask {36 readonly pattern: string;37 readonly options: GlobbyOptions;38 }39 interface GitignoreOptions {40 readonly cwd?: string;41 readonly ignore?: readonly string[];42 }43 type FilterFunction = (path: string) => boolean;44}45interface Gitignore {46 /**47 @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.48 */49 sync: (options?: globby.GitignoreOptions) => globby.FilterFunction;50 /**51 `.gitignore` files matched by the ignore config are not used for the resulting filter function.52 @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.53 @example54 ```55 import {gitignore} from 'globby';56 (async () => {57 const isIgnored = await gitignore();58 console.log(isIgnored('some/file'));59 })();60 ```61 */62 (options?: globby.GitignoreOptions): Promise<globby.FilterFunction>;63}64declare const globby: {65 /**66 Find files and directories using glob patterns.67 Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.68 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).69 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.70 @returns The matching paths.71 */72 sync: ((73 patterns: string | readonly string[],74 options: globby.GlobbyOptions & {objectMode: true}75 ) => globby.Entry[]) & ((76 patterns: string | readonly string[],77 options?: globby.GlobbyOptions78 ) => string[]);79 /**80 Find files and directories using glob patterns.81 Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.82 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).83 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.84 @returns The stream of matching paths.85 @example86 ```87 import globby = require('globby');88 (async () => {89 for await (const path of globby.stream('*.tmp')) {90 console.log(path);91 }92 })();93 ```94 */95 stream: (96 patterns: string | readonly string[],97 options?: globby.GlobbyOptions98 ) => NodeJS.ReadableStream;99 /**100 Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.101 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).102 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.103 @returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.104 */105 generateGlobTasks: (106 patterns: string | readonly string[],107 options?: globby.GlobbyOptions108 ) => globby.GlobTask[];109 /**110 Note that the options affect the results.111 This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).112 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).113 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3).114 @returns Whether there are any special glob characters in the `patterns`.115 */116 hasMagic: (117 patterns: string | readonly string[],118 options?: FastGlobOptions119 ) => boolean;120 readonly gitignore: Gitignore;121 (122 patterns: string | readonly string[],123 options: globby.GlobbyOptions & {objectMode: true}124 ): Promise<globby.Entry[]>;125 /**126 Find files and directories using glob patterns.127 Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.128 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).129 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.130 @returns The matching paths.131 @example132 ```133 import globby = require('globby');134 (async () => {135 const paths = await globby(['*', '!cake']);136 console.log(paths);137 //=> ['unicorn', 'rainbow']138 })();139 ```140 */141 (142 patterns: string | readonly string[],143 options?: globby.GlobbyOptions144 ): Promise<string[]>;145};...
index.mjs
Source:index.mjs
...46 return async arg => {47 const match = /^\{\{([\s\S]+)\}\}$/.exec(arg);48 if (!match) return [arg];49 const [, pattern] = match;50 return await globby(pattern, globbyOptions);51 };52}53/**54 * @template T55 * @param {T[][]} array56 * @returns {T[]}57 */58function flatArray(array) {59 return array.reduce((args, arg) => [...args, ...arg], []);60}61/**62 * @param {string} command63 * @param {readonly string[]} args64 * @param {import('child_process').SpawnOptions} options...
globby_vx.x.x.js
Source:globby_vx.x.x.js
1// flow-typed signature: 8f77d308b3b3fbe3fc41ae8026ea44e52// flow-typed version: <<STUB>>/globby_v^11.0.0/flow_v0.110.13/**4 * This is an autogenerated libdef stub for:5 *6 * 'globby'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'globby' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'globby/gitignore' {23 declare module.exports: any;24}25declare module 'globby/stream-utils' {26 declare module.exports: any;27}28// Filename aliases29declare module 'globby/gitignore.js' {30 declare module.exports: $Exports<'globby/gitignore'>;31}32declare module 'globby/index' {33 declare module.exports: $Exports<'globby'>;34}35declare module 'globby/index.js' {36 declare module.exports: $Exports<'globby'>;37}38declare module 'globby/stream-utils.js' {39 declare module.exports: $Exports<'globby/stream-utils'>;...
pkg.test.js
Source:pkg.test.js
1const globby = require("..");2describe("globby cjs", () => {3 test("should be defined", () => {4 expect(globby).toBeDefined();5 expect(globby.globby).toBeInstanceOf(Function);6 expect(globby.generateGlobTasks).toBeInstanceOf(Function);7 expect(globby.globbyStream).toBeInstanceOf(Function);8 expect(globby.globbySync).toBeInstanceOf(Function);9 expect(globby.isDynamicPattern).toBeInstanceOf(Function);10 expect(globby.isGitIgnored).toBeInstanceOf(Function);11 expect(globby.isGitIgnoredSync).toBeInstanceOf(Function);12 });...
Using AI Code Generation
1import test from 'ava';2import globby from 'globby';3import path from 'path';4test('globby', async t => {5 const files = await globby(['*.js', '!*.test.js'], {6 cwd: path.join(__dirname, 'fixtures')7 });8 t.deepEqual(files, ['fixture.js']);9});10{11 "scripts": {12 },13 "devDependencies": {14 }15}16export default function () {17 return 'fixture';18}19import test from 'ava';20import globby from 'globby';21import path from 'path';22test('globby', async t => {23 const files = await globby(['*.js', '!*.test.js'], {24 cwd: path.join(__dirname, 'fixtures')25 });26 t.deepEqual(files, ['fixture.js']);27});28{29 "scripts": {30 },31 "devDependencies": {32 },33 "ava": {34 }35}
Using AI Code Generation
1const globby = require('globby');2const files = await globby(['**/*.js', '!**/node_modules/**']);3console.log(files);4const fs = require('fs');5const path = require('path');6const directoryPath = path.join(__dirname, 'test');7fs.readdir(directoryPath, function (err, files) {8 if (err) {9 return console.log('Unable to scan directory: ' + err);10 }11 files.forEach(function (file) {12 console.log(file);13 });14});15const fs = require('fs');16const path = require('path');17const directoryPath = path.join(__dirname, 'test');18const files = fs.readdirSync(directoryPath)19files.forEach(function (file) {20 console.log(file);21});22const fs = require('fs');23const path = require('path');24const directoryPath = path.join(__dirname, 'test');25const files = fs.readdirSync(directoryPath)26files.forEach(function (file) {27 console.log(file);28});29const fs = require('fs');30const path = require('path');31const directoryPath = path.join(__dirname, 'test');32const files = fs.readdirSync(directoryPath)33files.forEach(function (file) {34 console.log(file);35});36const fs = require('fs');37const path = require('path');38const directoryPath = path.join(__dirname, 'test');39const files = fs.readdirSync(directoryPath)40files.forEach(function (file) {41 console.log(file);42});
Using AI Code Generation
1const globby = require('globby');2const files = globby.sync(['**/*.txt', '!**/node_modules/**']);3console.log(files);4const fs = require('fs');5const path = require('path');6const folder = 'C:\\Users\\User\\Desktop\\test';7const files = fs.readdirSync(folder);8console.log(files);
Using AI Code Generation
1const globby = require('globby');2const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);3const globby = require('globby');4const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);5const globby = require('globby');6const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);7const globby = require('globby');8const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);9const globby = require('globby');10const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);11const globby = require('globby');12const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);13const globby = require('globby');14const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);15const globby = require('globby');16const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);17const globby = require('globby');18const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);19const globby = require('globby');20const files = await globby(['**/*.js', '!**/node_modules/**', '!**/coverage/**', '!**/dist/**']);
Using AI Code Generation
1const globby = require('globby');2const path = require('path');3const files = globby.sync(['**/*.js'], { cwd: path.join(__dirname, 'src') });4console.log(files);5const glob = require('glob');6const path = require('path');7glob('**/*.js', { cwd: path.join(__dirname, 'src') }, (err, files) => {8 console.log(files);9});10console.log('Hello World!');11console.log('Hello World!');12console.log('Hello World!');13console.log('Hello World!');14console.log('Hello World!');15console.log('Hello World!');16console.log('Hello World!');17console.log('Hello World!');18console.log('Hello World!');19console.log('Hello World!');
Using AI Code Generation
1const globby = require("globby");2const fs = require("fs");3const path = require("path");4const file = fs.readFileSync(path.join(__dirname, "file.txt"), "utf8");5const files = globby.sync(file);6console.log(files);
Using AI Code Generation
1const globby = require('globby');2const files = globby.sync(['./**/*.js', '!./node_modules/**']);3console.log(files);4const fs = require('fs');5const path = require('path');6fs.readdir(path.resolve(__dirname), (err, files) => {7 files.forEach(file => {8 console.log(file);9 });10});11const fs = require('fs');12const path = require('path');13fs.readdirSync(path.resolve(__dirname)).forEach(file => {14 console.log(file);15});16const fs = require('fs');17const path = require('path');18fs.readdirSync(path.resolve(__dirname), (err, files) => {19 files.forEach(file => {20 console.log(file);21 });22});23const fs = require('fs');24const path = require('path');25fs.readdir(path.resolve(__dirname), (err, files) => {26 files.forEach(file => {27 console.log(file);28 });29});30const fs = require('fs');31const path = require('path');32fs.readdirSync(path.resolve(__dirname)).forEach(file => {33 console.log(file);34});35const fs = require('fs');36const path = require('path');37fs.readdirSync(path.resolve(__dirname), (err, files) => {38 files.forEach(file => {39 console.log(file);40 });41});42const fs = require('fs');43const path = require('path');44fs.readdir(path.resolve(__dirname), (err, files) => {45 files.forEach(file => {46 console.log(file);47 });48});49const fs = require('fs');50const path = require('path');51fs.readdirSync(path.resolve(__dirname)).forEach(file => {52 console.log(file);53});54const fs = require('fs');55const path = require('path');56fs.readdirSync(path.resolve(__dirname), (err, files) => {57 files.forEach(file => {58 console.log(file);59 });60});
Using AI Code Generation
1import globby from 'globby';2const availableFiles = globby.sync(['./src/**/*.{js,ts}']);3console.log(availableFiles);4import glob from 'glob';5glob('./src/**/*.{js,ts}', (err, files) => {6 console.log(files);7});8import find from 'find';9find.file(/\.js$|\.ts$/, './src', files => {10 console.log(files);11});12import fs from 'fs';13const availableFiles = fs.readdirSync('./src', { withFileTypes: true }).filter(dirent => dirent.isFile()).map(dirent => dirent.name);14console.log(availableFiles);15import readdirp from 'readdirp';16const availableFiles = readdirp('./src', { fileFilter: '*.js' });17console.log(availableFiles);18import readdir from 'readdir-enhanced';19const availableFiles = readdir.readdirSync('./src', { deep: true, filter: '*.js' });20console.log(availableFiles);21import readdirEnhanced from 'readdir-enhanced';22const availableFiles = readdirEnhanced.readdirSync('./src', { deep: true, filter: '*.js' });23console.log(availableFiles);24import readdirp from 'readdirp';25const availableFiles = readdirp('./src', { fileFilter: '*.js' });26console.log(availableFiles);27import readdirp from 'readdirp';28const availableFiles = readdirp('./src', { fileFilter: '*.js' });29console.log(availableFiles);30import readdirp from 'readdirp';31const availableFiles = readdirp('./src', { fileFilter: '*.js' });32console.log(availableFiles);33import readdirp from 'readdirp';34const availableFiles = readdirp('./src', { fileFilter: '*.js' });35console.log(availableFiles);36import readdirp from 'readdirp';
Using AI Code Generation
1const globby = require('globby');2const fs = require('fs');3const path = require('path');4const { promisify } = require('util');5const readFile = promisify(fs.readFile);6const writeFile = promisify(fs.writeFile);7const mkdir = promisify(fs.mkdir);8const copyFile = promisify(fs.copyFile);9const getFiles = async () => {10 const files = await globby(['./src/**/*.{html}']);11 return files;12};13const getFiles = async () => {14 const files = await globby(['./src/**/*.{html}']);15 return files;16};17const getFiles = async () => {18 const files = await globby(['./src/**/*.{html}']);19 return files;20};21const getFiles = async () => {22 const files = await globby(['./src/**/*.{html}']);23 return files;24};25const getFiles = async () => {26 const files = await globby(['./src/**/*.{html}']);27 return files;28};29const getFiles = async () => {30 const files = await globby(['./src/**/*.{html}']);31 return files;32};33const getFiles = async () => {34 const files = await globby(['./src/**/*.{html}']);35 return files;36};37const getFiles = async () => {38 const files = await globby(['./src/**/*.{html}']);39 return files;40};
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!!