How to use keepNodeModules method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

generator.test.js

Source:generator.test.js Github

copy

Full Screen

1const {join} = require('path');2const {readFileSync, renameSync} = require('fs');3const {describe, it} = require('mocha');4const {expect} = require('chai');5const helpers = require('yeoman-test');6const assert = require('yeoman-assert');7describe('Generator', function() {8 this.timeout(300000);9 /** @type {import('yeoman-test').RunContext} */10 let runContext;11 after(function() {12 runContext.cleanTestDirectory();13 });14 async function runGenerator({type, keepNodeModules: keep, example, tests}) {15 const oldContext = runContext;16 const oldModules = join(process.cwd(), 'node_modules');17 const config = ['vsc'];18 if (tests) {19 config.push('mocha');20 }21 runContext = helpers.run(join(__dirname, '../app')).withOptions({22 skipInstall: !!keep,23 forceInstall: true,24 force: true25 }).withPrompts({26 app_name: 'foo',27 config,28 template: type === 'js' ? 'js' : example || 'tsx'29 });30 await runContext;31 if (keep) {32 renameSync(oldModules, join(process.cwd(), 'node_modules'));33 }34 if (oldContext) {35 oldContext.cleanTestDirectory();36 }37 }38 function lint(files) {39 const eslint = require(process.cwd() + '/node_modules/eslint');40 const cli = new eslint.CLIEngine({extensions: ['.js', '.jsx', '.ts', '.tsx']});41 return cli.executeOnFiles(files);42 }43 describe('creates vanilla JavaScript projects', function() {44 before(() => runGenerator({type: 'js'}));45 it('creates package.json with correct content', function() {46 const json = JSON.parse(readFileSync('package.json', {encoding: 'utf-8'}));47 expect(json.main).to.equal('src/app.js');48 expect(json.scripts.test).to.equal('eslint .');49 expect(json.scripts.mocha).to.be.undefined;50 expect(json.scripts.start).to.equal('tabris serve -a');51 });52 it('creates settings.json with correct content', function() {53 const json = JSON.parse(readFileSync('.vscode/settings.json', {encoding: 'utf-8'}));54 expect(json['mochaExplorer.require']).to.be.undefined;55 });56 it('creates config.xml with correct id and version', function() {57 assert.fileContent('cordova/config.xml', /<widget id=".+.foo" version="0.1.0">/);58 });59 it('creates extensions.json with correct content', function() {60 const json = JSON.parse(readFileSync('.vscode/extensions.json', {encoding: 'utf-8'}));61 expect(json.recommendations).to.deep.equal(['dbaeumer.vscode-eslint']);62 });63 it('creates launch.json with correct content', function() {64 const json = JSON.parse(readFileSync('.vscode/launch.json', {encoding: 'utf-8'}));65 expect(json.version).to.equal('0.2.0');66 expect(json.configurations[0].name).to.equal('Debug Tabris on Android');67 expect(json.configurations[0].address).to.equal('${input:debugAddress}');68 expect(json.inputs[0].id).to.equal('debugAddress');69 });70 it('creates .tabrisignore with correct content', function() {71 const files = readFileSync('.tabrisignore', {encoding: 'utf-8'}).split('\n');72 expect(files).to.not.include('src/');73 expect(files).to.include('.eslintrc');74 expect(files).to.include('.gitignore');75 expect(files).to.include('.vscode/');76 expect(files).to.include('node_modules/**/*.d.ts');77 expect(files).to.include('node_modules/tabris/ClientMock.js');78 expect(files).to.include('README.md');79 expect(files).not.to.include('package-lock.json');80 });81 it('creates .gitignore with correct content', function() {82 const files = readFileSync('.gitignore', {encoding: 'utf-8'}).split('\n');83 expect(files).to.not.include('/dist/');84 expect(files).to.include('/build/');85 expect(files).to.include('node_modules/');86 });87 it('creates README.md with correct content', function() {88 const readme = readFileSync('README.md', {encoding: 'utf-8'});89 expect(readme).to.include('# foo');90 expect(readme).to.include('## Run');91 expect(readme).to.include('## Test');92 expect(readme).to.include('## Debugging');93 expect(readme).to.include('## Build');94 expect(readme).not.to.include('unit tests');95 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/developer-app\.html/);96 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#android/);97 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#ios/);98 });99 it('creates other files', function() {100 assert.file(['.eslintrc', 'src/app.js', '.vscode/tasks.json']);101 });102 it('creates code passing eslint check', function() {103 expect(lint('src')).to.include({warningCount: 0, errorCount: 0});104 });105 });106 describe('generates tsc-compiled JavaScript/JSX projects', function() {107 before(() => runGenerator({type: 'ts', example: 'jsx'}));108 it('creates config.xml with correct id and version', function() {109 assert.fileContent('cordova/config.xml', /<widget id=".+.foo" version="0.1.0">/);110 });111 it('creates package.json with correct content', function() {112 const json = JSON.parse(readFileSync('package.json', {encoding: 'utf-8'}));113 expect(json.main).to.equal('dist');114 expect(json.scripts.lint).to.equal('eslint --ext .js,.jsx,.ts,.tsx src');115 expect(json.scripts.test).to.equal('npm run build && npm run lint');116 expect(json.scripts.mocha).to.be.undefined;117 expect(json.scripts.build).to.equal('tsc -p .');118 expect(json.scripts.start).to.equal('tabris serve -a -w');119 expect(json.scripts.watch).to.equal('tsc -p . -w --preserveWatchOutput --inlineSourceMap');120 });121 it('creates extensions.json with correct content', function() {122 const json = JSON.parse(readFileSync('.vscode/extensions.json', {encoding: 'utf-8'}));123 expect(json.recommendations).to.deep.equal(['dbaeumer.vscode-eslint']);124 });125 it('creates launch.json with correct content', function() {126 const json = JSON.parse(readFileSync('.vscode/launch.json', {encoding: 'utf-8'}));127 expect(json.configurations.length).to.equal(1);128 });129 it('creates settings.json with correct content', function() {130 const json = JSON.parse(readFileSync('.vscode/settings.json', {encoding: 'utf-8'}));131 expect(json).to.deep.equal({132 'typescript.tsdk': 'node_modules/typescript/lib',133 'javascript.implicitProjectConfig.experimentalDecorators': true,134 'eslint.enable': true135 });136 });137 it('creates .tabrisignore with correct content', function() {138 const files = readFileSync('.tabrisignore', {encoding: 'utf-8'}).split('\n');139 expect(files).to.include('src/');140 expect(files).to.not.include('test/');141 expect(files).to.include('.eslintrc');142 expect(files).to.include('tsconfig.json');143 expect(files).to.include('.gitignore');144 expect(files).to.include('.vscode/');145 expect(files).to.include('node_modules/**/*.d.ts');146 expect(files).to.include('node_modules/tabris/ClientMock.js');147 expect(files).to.include('README.md');148 expect(files).not.to.include('package-lock.json');149 });150 it('creates .gitignore with correct content', function() {151 const files = readFileSync('.gitignore', {encoding: 'utf-8'}).split('\n');152 expect(files).to.include('/dist/');153 expect(files).to.include('/build/');154 expect(files).to.include('node_modules/');155 });156 it('creates README.md with correct content', function() {157 const readme = readFileSync('README.md', {encoding: 'utf-8'});158 expect(readme).to.include('# foo');159 expect(readme).to.include('## Run');160 expect(readme).to.include('## Test');161 expect(readme).to.include('## Debugging');162 expect(readme).to.include('## Build');163 expect(readme).not.to.include('unit tests');164 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/developer-app\.html/);165 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#android/);166 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#ios/);167 });168 it('creates other files', function() {169 assert.file([170 '.eslintrc',171 'src/index.jsx',172 '.vscode/tasks.json'173 ]);174 assert.noFile([175 'test/tsconfig.json',176 'test/sandbox.ts',177 'test/sandbox.test.ts',178 'test/App.test.ts'179 ]);180 });181 it('lints jsx example', async function() {182 expect(lint('src')).to.include({warningCount: 0, errorCount: 0});183 });184 });185 describe('generates TypeScript projects', function() {186 describe('without mocha tests', function() {187 before(() => runGenerator({type: 'ts'}));188 it('creates config.xml with correct id and version', function() {189 assert.fileContent('cordova/config.xml', /<widget id=".+.foo" version="0.1.0">/);190 });191 it('creates package.json with correct content', function() {192 const json = JSON.parse(readFileSync('package.json', {encoding: 'utf-8'}));193 expect(json.main).to.equal('dist');194 expect(json.scripts.lint).to.equal('eslint --ext .js,.jsx,.ts,.tsx src');195 expect(json.scripts.test).to.equal('npm run build && npm run lint');196 expect(json.scripts.mocha).to.be.undefined;197 expect(json.scripts.build).to.equal('tsc -p .');198 expect(json.scripts.start).to.equal('tabris serve -a -w');199 expect(json.scripts.watch).to.equal('tsc -p . -w --preserveWatchOutput --inlineSourceMap');200 });201 it('creates extensions.json with correct content', function() {202 const json = JSON.parse(readFileSync('.vscode/extensions.json', {encoding: 'utf-8'}));203 expect(json.recommendations).to.deep.equal(['dbaeumer.vscode-eslint']);204 });205 it('creates launch.json with correct content', function() {206 const json = JSON.parse(readFileSync('.vscode/launch.json', {encoding: 'utf-8'}));207 expect(json.configurations.length).to.equal(1);208 });209 it('creates settings.json with correct content', function() {210 const json = JSON.parse(readFileSync('.vscode/settings.json', {encoding: 'utf-8'}));211 expect(json).to.deep.equal({212 'typescript.tsdk': 'node_modules/typescript/lib',213 'javascript.implicitProjectConfig.experimentalDecorators': true,214 'eslint.enable': true215 });216 });217 it('creates .tabrisignore with correct content', function() {218 const files = readFileSync('.tabrisignore', {encoding: 'utf-8'}).split('\n');219 expect(files).to.include('src/');220 expect(files).to.not.include('test/');221 expect(files).to.include('.eslintrc');222 expect(files).to.include('tsconfig.json');223 expect(files).to.include('.gitignore');224 expect(files).to.include('.vscode/');225 expect(files).to.include('node_modules/**/*.d.ts');226 expect(files).to.include('node_modules/tabris/ClientMock.js');227 expect(files).to.include('README.md');228 expect(files).not.to.include('package-lock.json');229 });230 it('creates .gitignore with correct content', function() {231 const files = readFileSync('.gitignore', {encoding: 'utf-8'}).split('\n');232 expect(files).to.include('/dist/');233 expect(files).to.include('/build/');234 expect(files).to.include('node_modules/');235 });236 it('creates README.md with correct content', function() {237 const readme = readFileSync('README.md', {encoding: 'utf-8'});238 expect(readme).to.include('# foo');239 expect(readme).to.include('## Run');240 expect(readme).to.include('## Test');241 expect(readme).to.include('## Debugging');242 expect(readme).to.include('## Build');243 expect(readme).not.to.include('unit tests');244 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/developer-app\.html/);245 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#android/);246 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#ios/);247 });248 it('creates other files', function() {249 assert.file([250 '.eslintrc',251 'src/App.tsx',252 'src/index.ts',253 '.vscode/tasks.json'254 ]);255 assert.noFile([256 'test/tsconfig.json',257 'test/sandbox.ts',258 'test/sandbox.test.ts',259 'test/App.test.ts'260 ]);261 });262 it('lints jsx example', async function() {263 await runGenerator({type: 'ts', example: 'jsx', keepNodeModules: true});264 expect(lint('src')).to.include({warningCount: 0, errorCount: 0});265 });266 it('lints tsx example', async function() {267 await runGenerator({type: 'ts', example: 'tsx', keepNodeModules: true});268 expect(lint('src')).to.include({warningCount: 0, errorCount: 0});269 });270 it('lints mvp example', async function() {271 await runGenerator({type: 'ts', example: 'mvp', keepNodeModules: true});272 expect(lint('src')).to.include({warningCount: 0, errorCount: 0});273 });274 it('lints mvvm example', async function() {275 await runGenerator({type: 'ts', example: 'mvvm', keepNodeModules: true});276 expect(lint('src')).to.include({warningCount: 0, errorCount: 0});277 });278 });279 describe('with mocha tests', function() {280 before(() => runGenerator({type: 'ts', tests: true}));281 it('creates config.xml with correct id and version', function() {282 assert.fileContent('cordova/config.xml', /<widget id=".+.foo" version="0.1.0">/);283 });284 it('creates README.md with correct content', function() {285 const readme = readFileSync('README.md', {encoding: 'utf-8'});286 expect(readme).to.include('# foo');287 expect(readme).to.include('## Run');288 expect(readme).to.include('## Test');289 expect(readme).to.include('## Debugging');290 expect(readme).to.include('## Build');291 expect(readme).to.include(292 '\n\nTabris.js unit tests support any debugger that works with Node.js. In Visual '293 );294 expect(readme).to.include('in the debug sidebar.\n\n#');295 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/developer-app\.html/);296 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#android/);297 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#ios/);298 });299 it('creates extensions.json with correct content', function() {300 const json = JSON.parse(readFileSync('.vscode/extensions.json', {encoding: 'utf-8'}));301 expect(json.recommendations).to.deep.equal([302 'dbaeumer.vscode-eslint',303 'hbenl.vscode-mocha-test-adapter'304 ]);305 });306 it('creates launch.json with correct content', function() {307 const json = JSON.parse(readFileSync('.vscode/launch.json', {encoding: 'utf-8'}));308 expect(json.configurations.length).to.equal(3);309 });310 it('creates settings.json with correct content', function() {311 const json = JSON.parse(readFileSync('.vscode/settings.json', {encoding: 'utf-8'}));312 expect(json).to.deep.equal({313 'mochaExplorer.require': 'ts-node/register',314 'mochaExplorer.files': 'test/**/*.test.*',315 'typescript.tsdk': 'node_modules/typescript/lib',316 'javascript.implicitProjectConfig.experimentalDecorators': true,317 'eslint.enable': true318 });319 });320 it('creates .tabrisignore with correct content', function() {321 const files = readFileSync('.tabrisignore', {encoding: 'utf-8'}).split('\n');322 expect(files).to.include('src/');323 expect(files).to.include('test/');324 expect(files).to.include('.eslintrc');325 expect(files).to.include('tsconfig.json');326 expect(files).to.include('.gitignore');327 expect(files).to.include('.vscode/');328 expect(files).to.include('node_modules/**/*.d.ts');329 expect(files).to.include('node_modules/tabris/ClientMock.js');330 expect(files).to.include('README.md');331 expect(files).not.to.include('package-lock.json');332 });333 it('creates .gitignore with correct content', function() {334 const files = readFileSync('.gitignore', {encoding: 'utf-8'}).split('\n');335 expect(files).to.include('/dist/');336 expect(files).to.include('/build/');337 expect(files).to.include('node_modules/');338 });339 it('creates README.md with correct content', function() {340 const readme = readFileSync('README.md', {encoding: 'utf-8'});341 expect(readme).to.include('# foo');342 expect(readme).to.include('## Run');343 expect(readme).to.include('## Test');344 expect(readme).to.include('## Debugging');345 expect(readme).to.include('## Build');346 expect(readme).to.include(347 '\n\nTabris.js unit tests support any debugger that works with Node.js. In Visual '348 );349 expect(readme).to.include('in the debug sidebar.\n\n#');350 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/developer-app\.html/);351 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#android/);352 expect(readme).to.match(/https:\/\/docs\.tabris\.com\/3\.[0-9]\/debug\.html#ios/);353 });354 it('creates other files', function() {355 assert.file([356 '.eslintrc',357 'src/App.tsx',358 'src/index.ts',359 '.vscode/tasks.json',360 'test/tsconfig.json',361 'test/sandbox.ts',362 'test/sandbox.test.ts',363 'test/App.test.ts'364 ]);365 });366 it('lints tsx example tests', async function() {367 await runGenerator({type: 'ts', example: 'tsx', keepNodeModules: true, tests: true});368 expect(lint('test')).to.include({warningCount: 0, errorCount: 0});369 });370 it('lints mvp example tests', async function() {371 await runGenerator({type: 'ts', example: 'mvp', keepNodeModules: true, tests: true});372 expect(lint('test')).to.include({warningCount: 0, errorCount: 0});373 });374 it('lints mvvm example tests', async function() {375 await runGenerator({type: 'ts', example: 'mvvm', keepNodeModules: true, tests: true});376 expect(lint('test')).to.include({warningCount: 0, errorCount: 0});377 });378 });379 });...

Full Screen

Full Screen

packaged.spec.ts

Source:packaged.spec.ts Github

copy

Full Screen

1import { promises as fs } from 'fs';2import * as path from 'path';3import { removeNonPublishedFiles } from '../src/packaged';4describe('removeNonPublishedFiles', () => {5 it.each`6 name | dryRun | keepNodeModules | pathStyle7 ${'only keep published files by default'} | ${false} | ${false} | ${'absolute'}8 ${'only keep published files and node_modules at root when requested'} | ${false} | ${true} | ${'absolute'}9 ${'not clean anything in dryRun mode even without keepNodeModules'} | ${true} | ${false} | ${'absolute'}10 ${'not clean anything in dryRun mode even with keepNodeModules'} | ${true} | ${true} | ${'absolute'}11 ${'handle relative paths such as .'} | ${false} | ${false} | ${'.'}12 ${'handle relative paths such as ./package-name'} | ${false} | ${false} | ${'./package-name'}13 ${'handle relative paths such as ./a/package-name'} | ${false} | ${false} | ${'./a/package-name'}14 ${'handle relative paths such as ./a/../a/package-name/'} | ${false} | ${false} | ${'./a/../a/package-name/'}15 `('should $name', async ({ dryRun, keepNodeModules, pathStyle }) => {16 await runPackageTest(async (fileSystem) => {17 // Arrange18 const packageJsonContent = {19 name: 'my-package',20 version: '0.0.0',21 files: ['lib'],22 license: 'MIT',23 };24 await fileSystem.createFile(['package.json'], JSON.stringify(packageJsonContent));25 await fileSystem.createFile(['lib', 'main.js'], 'console.log("main.js")');26 await fileSystem.createFile(['src', 'main.js'], 'console.log("main.js")');27 await fileSystem.createFile(['src', 'node_modules', 'wtf', 'main.js'], 'console.log("main.js")');28 await fileSystem.createFile(['test', 'main.js'], 'console.log("main.js")');29 await fileSystem.createFile(['node_modules', 'dep-a', 'main.js'], 'console.log("main.js")');30 // Act31 let requestedPath = '';32 const lastFolderName = path.basename(fileSystem.packagePath);33 const beforeLastFolderName = path.basename(path.dirname(fileSystem.packagePath));34 switch (pathStyle) {35 case 'absolute':36 requestedPath = fileSystem.packagePath;37 break;38 case '.':39 process.chdir(fileSystem.packagePath);40 requestedPath = pathStyle;41 break;42 case './package-name':43 process.chdir(path.join(fileSystem.packagePath, '..'));44 requestedPath = `./${lastFolderName}`;45 break;46 case './a/package-name':47 process.chdir(path.join(fileSystem.packagePath, '..', '..'));48 requestedPath = `./${beforeLastFolderName}/${lastFolderName}`;49 break;50 case './a/../a/package-name/':51 process.chdir(path.join(fileSystem.packagePath, '..', '..'));52 requestedPath = `./${beforeLastFolderName}/../${beforeLastFolderName}/${lastFolderName}`;53 break;54 default:55 throw new Error(`Unsupported style ${pathStyle}`);56 }57 const { kept, removed } = await removeNonPublishedFiles(requestedPath, { dryRun, keepNodeModules });58 // Assert59 // Returns arrays having the expected sizes60 if (!keepNodeModules) {61 expect(kept).toHaveLength(3); // package.json, lib/main.js, lib62 expect(removed).toHaveLength(10); // src/main.js, src, test/main.js, test, node_modules/dep-a/main.js, node_modules/dep-a, node_modules, src/node_modules/wtf/main.js, src/node_modules/wtf, src/node_modules63 } else {64 expect(kept).toHaveLength(4); // package.json, lib/main.js, lib, node_modules/*65 expect(removed).toHaveLength(7); // src/main.js, src, test/main.js, test, src/node_modules/wtf/main.js, src/node_modules/wtf, src/node_modules66 }67 // Remove unpublished files and keep published ones68 expect(await fileSystem.exists(['package.json'])).toBe(true);69 expect(await fileSystem.exists(['lib', 'main.js'])).toBe(true);70 expect(await fileSystem.exists(['src', 'main.js'])).toBe(dryRun);71 expect(await fileSystem.exists(['src', 'node_modules', 'wtf', 'main.js'])).toBe(dryRun);72 expect(await fileSystem.exists(['test', 'main.js'])).toBe(dryRun);73 expect(await fileSystem.exists(['node_modules', 'dep-a', 'main.js'])).toBe(dryRun || keepNodeModules);74 // Remove empty folders75 expect(await fileSystem.exists(['src'])).toBe(dryRun);76 expect(await fileSystem.exists(['src', 'node_modules'])).toBe(dryRun);77 expect(await fileSystem.exists(['src', 'node_modules', 'wtf'])).toBe(dryRun);78 expect(await fileSystem.exists(['test'])).toBe(dryRun);79 expect(await fileSystem.exists(['node_modules'])).toBe(dryRun || keepNodeModules);80 expect(await fileSystem.exists(['node_modules', 'dep-a'])).toBe(dryRun || keepNodeModules);81 });82 });83 it('should handle packages relying on .npmignore', async () => {84 await runPackageTest(async (fileSystem) => {85 // Arrange86 const packageJsonContent = {87 name: 'my-package',88 version: '0.0.0',89 license: 'MIT',90 };91 await fileSystem.createFile(['package.json'], JSON.stringify(packageJsonContent));92 await fileSystem.createFile(['lib', 'main.js'], 'console.log("main.js")');93 await fileSystem.createFile(['src', 'main.js'], 'console.log("main.js")');94 await fileSystem.createFile(['src2', 'main.js'], 'console.log("main.js")');95 await fileSystem.createFile(['.npmignore'], 'src');96 // Act97 const { kept, removed } = await removeNonPublishedFiles(fileSystem.packagePath);98 // Assert99 expect(kept).toHaveLength(5); // package.sjon, lib/main.js, lib, src2/main.js, src2100 expect(removed).toHaveLength(3); // .npmignore, src/main.js, src101 expect(await fileSystem.exists(['package.json'])).toBe(true);102 expect(await fileSystem.exists(['lib', 'main.js'])).toBe(true);103 expect(await fileSystem.exists(['src2', 'main.js'])).toBe(true);104 expect(await fileSystem.exists(['src'])).toBe(false);105 expect(await fileSystem.exists(['.npmignore'])).toBe(false);106 });107 });108});109// Helpers110type FilePathChunks = [string, ...string[]];111type RunnerFileSystem = {112 packagePath: string;113 createFile: (filePathChunks: FilePathChunks, fileContent: string) => Promise<void>;114 exists: (filePathChunks: FilePathChunks) => Promise<boolean>;115};116async function runPackageTest(runner: (fileSystem: RunnerFileSystem) => Promise<void>): Promise<void> {117 const initialWorkingDirectory = process.cwd();118 const packageName = `random-package-${Date.now().toString(16)}-${Math.random().toString(16).substring(2)}`;119 const packagePath = path.join(__dirname, packageName);120 try {121 const fileSystem: RunnerFileSystem = {122 packagePath,123 async createFile(filePathChunks, fileContent) {124 const directoryPath = path.join(packagePath, ...filePathChunks.slice(0, -1));125 await fs.mkdir(directoryPath, { recursive: true });126 const filePath = path.join(packagePath, ...filePathChunks);127 await fs.writeFile(filePath, fileContent);128 },129 async exists(filePathChunks) {130 const filePath = path.join(packagePath, ...filePathChunks);131 return fs.access(filePath).then(132 () => true,133 () => false134 );135 },136 };137 await runner(fileSystem);138 } finally {139 process.chdir(initialWorkingDirectory);140 await fs.rm(packagePath, { recursive: true });141 }142 return;...

Full Screen

Full Screen

hoist.ts

Source:hoist.ts Github

copy

Full Screen

1import {BaseCommand} from "./baseCommand";2import {ActionCallback, Logger} from "../types";3import * as caporal from 'caporal';4import {InstallCommand} from "./install";5import {LernaUtil} from "..";6import * as path from "path";7import * as rimraf from "rimraf";8import {promisify} from 'util';9export interface HoistOptions {10 keepNodeModules?: boolean;11}12const rmrf = promisify(rimraf);13export class HoistCommand extends BaseCommand {14 static noHoist: string[] = [];15 getHandler(): ActionCallback {16 return async (args: any, options: HoistOptions, logger: Logger): Promise<void> => {17 this.spinner.info("Removing node modules for all the packages");18 if (!options.keepNodeModules) {19 await this.removeAllNodeModules();20 }21 this.spinner.succeed("Removed successfully");22 await this.updateLernaConfigurations();23 await new InstallCommand().getHandler()({}, {}, logger);24 }25 }26 private async removeAllNodeModules() {27 let lerna = await (new LernaUtil().parse(path.join(process.cwd(), 'lerna.json')));28 const packageFolders = lerna.packageFolders;29 await Promise.all([30 ...packageFolders.map((folderName: string) => {31 const nodeModulesPath = path.join(folderName, "node_modules");32 return rmrf(nodeModulesPath);33 }),34 rmrf(path.join(process.cwd(), 'node_modules'))]);35 }36 private async updateLernaConfigurations() {37 const lerna = await this.getDocument('lerna.json');38 lerna.content.hoist = true;39 lerna.content.nohoist = HoistCommand.noHoist;40 await lerna.write();41 }42}43const hoistCommand = new HoistCommand();44caporal.command('hoist', 'convert a workspace to be a hoisted workspace')45 .option('--keep-node-modules', 'do not remove node modules for all packages', caporal.BOOLEAN, false)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { keepNodeModules } = require('fast-check-monorepo');2keepNodeModules('test3');3const { keepNodeModules } = require('fast-check-monorepo');4keepNodeModules('test4');5const { keepNodeModules } = require('fast-check-monorepo');6keepNodeModules('test5');7const { keepNodeModules } = require('fast-check-monorepo');8keepNodeModules('test6');9const { keepNodeModules } = require('fast-check-monorepo');10keepNodeModules('test7');11const { keepNodeModules } = require('fast-check-monorepo');12keepNodeModules('test8');13const { keepNodeModules } = require('fast-check-monorepo');14keepNodeModules('test9');15const { keepNodeModules } = require('fast-check-monorepo');16keepNodeModules('test10');17const { keepNodeModules } = require('fast-check-monorepo');18keepNodeModules('test11');19const { keepNodeModules } = require('fast-check-monorepo');20keepNodeModules('test12');21const { keepNodeModules } = require('fast-check-monorepo');22keepNodeModules('test13');23const { keepNodeModules } = require('fast-check-monorepo

Full Screen

Using AI Code Generation

copy

Full Screen

1const { keepNodeModules } = require('fast-check-monorepo')2keepNodeModules(__dirname, 1, 2)3const { keepNodeModules } = require('fast-check-monorepo')4keepNodeModules(__dirname, 1, 2)5const { keepNodeModules } = require('fast-check-monorepo')6keepNodeModules(__dirname, 1, 2)7const { keepNodeModules } = require('fast-check-monorepo')8keepNodeModules(__dirname, 1, 2)9const { keepNodeModules } = require('fast-check-monorepo')10keepNodeModules(__dirname, 1, 2)11const { keepNodeModules } = require('fast-check-monorepo')12keepNodeModules(__dirname, 1, 2)13const { keepNodeModules } = require('fast-check-monorepo')14keepNodeModules(__dirname, 1, 2)15const { keepNodeModules } = require('fast-check-monorepo')16keepNodeModules(__dirname, 1, 2)17const { keepNodeModules } = require('fast-check-monorepo')18keepNodeModules(__dirname, 1, 2)19const { keepNodeModules } = require('fast-check-monorepo')20keepNodeModules(__dirname, 1, 2)21const { keepNodeModules } = require

Full Screen

Using AI Code Generation

copy

Full Screen

1const { keepNodeModules } = require('fast-check-monorepo');2const { installNodeModules } = require('./test1');3const { installNodeModules } = require('fast-check-monorepo');4const { keepNodeModules } = require('./test2');5const { installNodeModules } = require('fast-check');6const { keepNodeModules } = require('./test3');7const { keepNodeModules } = require('fast-check');8const { installNodeModules } = require('./test4');9const { keepNodeModules } = require('fast-check');10const { installNodeModules } = require('./test1');11const { installNodeModules } = require('fast-check');12const { keepNodeModules } = require('./test2');13const { installNodeModules } = require('fast-check-monorepo');14const { keepNodeModules } = require('./test3');15const { keepNodeModules } = require('fast-check-monorepo');16const { installNodeModules } = require('./test4');17const { keepNodeModules } = require('fast-check-monorepo');18const { installNodeModules } = require('./test1');19const { installNodeModules } = require('fast-check-monorepo');20const { keepNodeModules } = require('./test2');21const { installNodeModules } = require('fast-check');22const { keepNodeModules } = require('./test3');23const { keepNodeModules } = require('fast-check');24const { installNodeModules } = require('./test4');25const { keepNodeModules } = require('fast-check-monorepo');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { keepNodeModules } = require('fast-check-monorepo-helper');2keepNodeModules();3const { keepNodeModules } = require('fast-check-monorepo-helper');4keepNodeModules();5const { keepNodeModules } = require('fast-check-monorepo-helper');6keepNodeModules();7const { keepNodeModules } = require('fast-check-monorepo-helper');8keepNodeModules();9const { keepNodeModules } = require('fast-check-monorepo-helper');10keepNodeModules();11const { keepNodeModules } = require('fast-check-monorepo-helper');12keepNodeModules();13const { keepNodeModules } = require('fast-check-monorepo-helper');14keepNodeModules();15const { keepNodeModules } = require('fast-check-monorepo-helper');16keepNodeModules();17const { keepNodeModules } = require('fast-check-monorepo-helper');18keepNodeModules();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { keepNodeModules } = require('fast-check-monorepo');2const { property } = require('fast-check');3const { property } = require('fast-check/lib/cjs/fast-check-default');4const { property } = require('fast-check/lib/cjs/fast-check-default');5keepNodeModules();6const { property } = require('fast-check/lib/cjs/fast-check-default');7keepNodeModules('other/path/to/node_modules');8const { property } = require('fast-check/lib/cjs/fast-check-default');9keepNodeModules('other/path/to/node_modules');10const { property } = require('fast-check/lib/cjs/fast-check-default');11keepNodeModules('other/path/to/node_modules');12const { property } = require('fast-check/lib/cjs/fast-check-default');13keepNodeModules('other/path/to/node_modules');14const { property } = require('fast-check/lib/cjs/fast-check-default');15keepNodeModules('other/path/to/node_modules');16const { property } = require('fast-check/lib/cjs/fast-check-default');17keepNodeModules('other/path/to/node_modules');18const { property } = require('fast-check/lib/cjs/fast-check-default');19keepNodeModules('other/path/to/node_modules');20const { property } = require('fast-check/lib/cjs/fast-check-default');21keepNodeModules('other/path/to/node_modules');22const { property } = require('fast-check/lib/cjs/fast-check-default');23keepNodeModules('other/path/to/node_modules');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { keepNodeModules } = require('fast-check-monorepo');2keepNodeModules();3const { keepNodeModules } = require('fast-check-monorepo');4keepNodeModules();5const { keepNodeModules } = require('fast-check-monorepo');6keepNodeModules();7const { keepNodeModules } = require('fast-check-monorepo');8keepNodeModules();9const { keepNodeModules } = require('fast-check-monorepo');10keepNodeModules();11const { keepNodeModules } = require('fast-check-monorepo');12keepNodeModules();13const { keepNodeModules } = require('fast-check-monorepo');14keepNodeModules();15const { keepNodeModules } = require('fast-check-monorepo');16keepNodeModules();

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful