How to use fileExists method in storybook-root

Best JavaScript code snippet using storybook-root

pack-files-and-ignores.js

Source:pack-files-and-ignores.js Github

copy

Full Screen

...28 notincluded: File('')29 })30 )31 withFixture(t, fixture, function (done) {32 t.ok(fileExists('include'), 'toplevel file included')33 t.ok(fileExists('sub/include'), 'nested file included')34 t.notOk(fileExists('notincluded'), 'unspecified file not included')35 done()36 })37})38test('basic file exclusion', function (t) {39 var fixture = new Tacks(40 Dir({41 'package.json': File({42 name: 'npm-test-files',43 version: '1.2.5'44 }),45 '.npmignore': File(46 'ignore\n' +47 'sub/ignore\n'48 ),49 include: File(''),50 ignore: File(''),51 sub: Dir({ ignore: File('') })52 })53 )54 withFixture(t, fixture, function (done) {55 t.notOk(fileExists('ignore'), 'toplevel file excluded')56 t.notOk(fileExists('sub/ignore'), 'nested file excluded')57 t.ok(fileExists('include'), 'unignored file included')58 done()59 })60})61test('toplevel-only and blanket ignores', function (t) {62 var fixture = new Tacks(63 Dir({64 'package.json': File({65 name: 'npm-test-files',66 version: '1.2.5'67 }),68 '.npmignore': File(69 './shallow1\n' +70 '/shallow2\n' +71 '/sub/onelevel\n' +72 'deep\n' +73 ''74 ),75 shallow1: File(''),76 shallow2: File(''),77 deep: File(''),78 sub: Dir({79 shallow1: File(''),80 shallow2: File(''),81 onelevel: File(''),82 deep: File(''),83 sub: Dir({84 deep: File(''),85 onelevel: File('')86 })87 })88 })89 )90 withFixture(t, fixture, function (done) {91 t.notOk(fileExists('shallow2'), '/ file excluded')92 t.ok(fileExists('sub/shallow1'), 'nested ./ file included')93 t.ok(fileExists('sub/shallow2'), 'nested / file included')94 t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')95 t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')96 t.notOk(fileExists('deep'), 'deep file excluded')97 t.notOk(fileExists('sub/deep'), 'nested deep file excluded')98 t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')99 t.ok(fileExists('shallow1'), './ file included')100 done()101 })102})103test('.npmignore works for nested directories recursively', function (t) {104 var fixture = new Tacks(105 Dir({106 'package.json': File({107 name: 'npm-test-files',108 version: '1.2.5'109 }),110 '.npmignore': File(111 '/ignore\n' +112 'deep\n'113 ),114 include: File(''),115 ignore: File(''),116 deep: File(''),117 sub: Dir({118 ignore: File(''),119 include: File(''),120 deep: File(''),121 sub: Dir({122 '.npmignore': File(123 '/ignore\n'124 ),125 ignore: File(''),126 include: File(''),127 deep: File('')128 })129 })130 })131 )132 withFixture(t, fixture, function (done) {133 t.notOk(fileExists('ignore'), 'toplevel file excluded')134 t.ok(fileExists('include'), 'unignored file included')135 t.ok(fileExists('sub/ignore'), 'same-name file in nested dir included')136 t.ok(fileExists('sub/include'), 'unignored nested dir file included')137 t.notOk(fileExists('sub/sub/ignore'), 'sub-sub-directory file excluded')138 t.ok(fileExists('sub/sub/include'), 'sub-sube-directory file included')139 t.notOk(fileExists('deep'), 'deep file excluded')140 t.notOk(fileExists('sub/deep'), 'sub-dir deep file excluded')141 t.notOk(fileExists('sub/sub/deep'), 'sub-sub-dir deep file excluded')142 done()143 })144})145test('.gitignore should have identical semantics', function (t) {146 var fixture = new Tacks(147 Dir({148 'package.json': File({149 name: 'npm-test-files',150 version: '1.2.5'151 }),152 '.gitignore': File(153 './shallow1\n' +154 '/shallow2\n' +155 '/sub/onelevel\n' +156 'deep\n' +157 ''158 ),159 shallow1: File(''),160 shallow2: File(''),161 deep: File(''),162 sub: Dir({163 shallow1: File(''),164 shallow2: File(''),165 onelevel: File(''),166 deep: File(''),167 sub: Dir({168 deep: File(''),169 onelevel: File('')170 })171 })172 })173 )174 withFixture(t, fixture, function (done) {175 t.notOk(fileExists('shallow2'), '/ file excluded')176 t.ok(fileExists('sub/shallow1'), 'nested ./ file included')177 t.ok(fileExists('sub/shallow2'), 'nested / file included')178 t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')179 t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')180 t.notOk(fileExists('deep'), 'deep file excluded')181 t.notOk(fileExists('sub/deep'), 'nested deep file excluded')182 t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')183 t.ok(fileExists('shallow1'), './ file included')184 done()185 })186})187test('.npmignore should always be overridden by files array', function (t) {188 var fixture = new Tacks(189 Dir({190 'package.json': File({191 name: 'npm-test-files',192 version: '1.2.5',193 files: [194 'include',195 'sub'196 ]197 }),198 '.npmignore': File(199 'include\n' +200 'ignore\n' +201 'sub/included\n'202 ),203 include: File(''),204 ignore: File(''),205 sub: Dir({206 included: File('')207 })208 })209 )210 withFixture(t, fixture, function (done) {211 t.notOk(fileExists('ignore'), 'toplevel file excluded')212 t.ok(fileExists('include'), 'unignored file included')213 t.ok(fileExists('sub/included'), 'nested file included')214 done()215 })216})217test('.gitignore supported for ignores', function (t) {218 var fixture = new Tacks(219 Dir({220 'package.json': File({221 name: 'npm-test-files',222 version: '1.2.5'223 }),224 '.gitignore': File(225 'ignore\n' +226 'sub/ignore\n'227 ),228 include: File(''),229 ignore: File(''),230 sub: Dir({ ignore: File('') })231 })232 )233 withFixture(t, fixture, function (done) {234 t.notOk(fileExists('ignore'), 'toplevel file excluded')235 t.notOk(fileExists('sub/ignore'), 'nested file excluded')236 t.ok(fileExists('include'), 'unignored file included')237 done()238 })239})240test('.npmignore completely overrides .gitignore', function (t) {241 var fixture = new Tacks(242 Dir({243 'package.json': File({244 name: 'npm-test-files',245 version: '1.2.5'246 }),247 '.npmignore': File(248 'ignore\n' +249 'sub/ignore\n'250 ),251 '.gitignore': File(252 'include\n' +253 'sub/include\n' +254 'extra\n'255 ),256 include: File(''),257 sub: Dir({ include: File('') }),258 extra: File('')259 })260 )261 withFixture(t, fixture, function (done) {262 t.ok(fileExists('include'), 'gitignored toplevel file included')263 t.ok(fileExists('extra'), 'gitignored extra toplevel file included')264 t.ok(fileExists('sub/include'), 'gitignored nested file included')265 t.notOk(fileExists('ignore'), 'toplevel file excluded')266 t.notOk(fileExists('sub/ignore'), 'nested file excluded')267 done()268 })269})270test('files array overrides .npmignore', function (t) {271 var fixture = new Tacks(272 Dir({273 'package.json': File({274 name: 'npm-test-files',275 version: '1.2.5',276 files: [277 'include',278 'sub/include'279 ]280 }),281 '.npmignore': File(282 'include\n' +283 'sub/include\n'284 ),285 include: File(''),286 sub: Dir({ include: File('') })287 })288 )289 withFixture(t, fixture, function (done) {290 t.ok(fileExists('include'), 'toplevel file included')291 t.ok(fileExists('sub/include'), 'nested file included')292 done()293 })294})295test('includes files regardless of emptiness', function (t) {296 var fixture = new Tacks(297 Dir({298 'package.json': File({299 name: 'npm-test-files',300 version: '1.2.5',301 files: [302 'full',303 'empty'304 ]305 }),306 full: File('This file has contents~'),307 empty: File('')308 })309 )310 withFixture(t, fixture, function (done) {311 t.ok(fileExists('full'), 'contentful file included')312 t.ok(fileExists('empty'), 'empty file included')313 done()314 })315})316test('.npmignore itself gets included', function (t) {317 var fixture = new Tacks(318 Dir({319 'package.json': File({320 name: 'npm-test-files',321 version: '1.2.5',322 files: [323 '.npmignore'324 ]325 }),326 '.npmignore': File('')327 })328 )329 withFixture(t, fixture, function (done) {330 t.ok(fileExists('.npmignore'), '.npmignore included')331 done()332 })333})334test('include default files when missing files spec', function (t) {335 var fixture = new Tacks(336 Dir({337 'package.json': File({338 name: 'npm-test-files',339 version: '1.2.5'340 }),341 'index.js': File(''),342 foo: File(''),343 node_modules: Dir({foo: Dir({bar: File('')})})344 })345 )346 withFixture(t, fixture, function (done) {347 t.ok(fileExists('index.js'), 'index.js included')348 t.ok(fileExists('foo'), 'foo included')349 t.notOk(fileExists('node_modules'), 'node_modules not included')350 done()351 })352})353test('include main file', function (t) {354 var fixture = new Tacks(355 Dir({356 'package.json': File({357 name: 'npm-test-files',358 version: '1.2.5',359 main: 'foo.js',360 files: []361 }),362 'index.js': File(''),363 'foo.js': File('')364 })365 )366 withFixture(t, fixture, function (done) {367 t.ok(fileExists('foo.js'), 'foo.js included because of main')368 t.notOk(fileExists('index.js'), 'index.js not included')369 done()370 })371})372test('certain files ignored by default', function (t) {373 var fixture = new Tacks(374 Dir({375 'package.json': File({376 name: 'npm-test-files',377 version: '1.2.5'378 }),379 '.git': Dir({foo: File('')}),380 '.svn': Dir({foo: File('')}),381 'CVS': Dir({foo: File('')}),382 '.hg': Dir({foo: File('')}),383 '.lock-wscript': File(''),384 '.wafpickle-0': File(''),385 '.wafpickle-5': File(''),386 '.wafpickle-50': File(''),387 'build': Dir({'config.gypi': File('')}),388 'npm-debug.log': File(''),389 '.npmrc': File(''),390 '.foo.swp': File(''),391 'core': Dir({core: File(''), foo: File('')}),392 '.DS_Store': Dir({foo: File('')}),393 '._ohno': File(''),394 '._ohnoes': Dir({noes: File('')}),395 'foo.orig': File(''),396 'package-lock.json': File('')397 })398 )399 withFixture(t, fixture, function (done) {400 t.notOk(fileExists('.git'), '.git not included')401 t.notOk(fileExists('.svn'), '.svn not included')402 t.notOk(fileExists('CVS'), 'CVS not included')403 t.notOk(fileExists('.hg'), '.hg not included')404 t.notOk(fileExists('.lock-wscript'), '.lock-wscript not included')405 t.notOk(fileExists('.wafpickle-0'), '.wafpickle-0 not included')406 t.notOk(fileExists('.wafpickle-5'), '.wafpickle-5 not included')407 t.notOk(fileExists('.wafpickle-50'), '.wafpickle-50 not included')408 t.notOk(fileExists('build/config.gypi'), 'build/config.gypi not included')409 t.notOk(fileExists('npm-debug.log'), 'npm-debug.log not included')410 t.notOk(fileExists('.npmrc'), '.npmrc not included')411 t.notOk(fileExists('.foo.swp'), '.foo.swp not included')412 t.ok(fileExists('core'), 'core/ included')413 t.ok(fileExists('core/foo'), 'core/foo included')414 t.notOk(fileExists('core/core'), 'core/core not included')415 t.notOk(fileExists('.DS_Store'), '.DS_Store not included')416 t.notOk(fileExists('.DS_Store/foo'), '.DS_Store/foo not included')417 t.notOk(fileExists('._ohno'), '._ohno not included')418 t.notOk(fileExists('._ohnoes'), '._ohnoes not included')419 t.notOk(fileExists('foo.orig'), 'foo.orig not included')420 t.notOk(fileExists('package-lock.json'), 'package-lock.json not included')421 done()422 })423})424test('default-ignored files can be explicitly included', function (t) {425 var fixture = new Tacks(426 Dir({427 'package.json': File({428 name: 'npm-test-files',429 version: '1.2.5',430 files: [431 '.git',432 '.svn',433 'CVS',434 '.hg',435 '.lock-wscript',436 '.wafpickle-0',437 '.wafpickle-5',438 '.wafpickle-50',439 'build/config.gypi',440 'npm-debug.log',441 '.npmrc',442 '.foo.swp',443 'core',444 '.DS_Store',445 '._ohno',446 '._ohnoes',447 'foo.orig',448 'package-lock.json'449 ]450 }),451 '.git': Dir({foo: File('')}),452 '.svn': Dir({foo: File('')}),453 'CVS': Dir({foo: File('')}),454 '.hg': Dir({foo: File('')}),455 '.lock-wscript': File(''),456 '.wafpickle-0': File(''),457 '.wafpickle-5': File(''),458 '.wafpickle-50': File(''),459 'build': Dir({'config.gypi': File('')}),460 'npm-debug.log': File(''),461 '.npmrc': File(''),462 '.foo.swp': File(''),463 'core': Dir({core: File(''), foo: File('')}),464 '.DS_Store': Dir({foo: File('')}),465 '._ohno': File(''),466 '._ohnoes': Dir({noes: File('')}),467 'foo.orig': File(''),468 'package-lock.json': File('')469 })470 )471 withFixture(t, fixture, function (done) {472 t.notOk(fileExists('.git'), '.git should never be included')473 t.ok(fileExists('.svn'), '.svn included')474 t.ok(fileExists('CVS'), 'CVS included')475 t.ok(fileExists('.hg'), '.hg included')476 t.ok(fileExists('.lock-wscript'), '.lock-wscript included')477 t.ok(fileExists('.wafpickle-0'), '.wafpickle-0 included')478 t.ok(fileExists('.wafpickle-5'), '.wafpickle-5 included')479 t.ok(fileExists('.wafpickle-50'), '.wafpickle-50 included')480 t.ok(fileExists('build/config.gypi'), 'build/config.gypi included')481 t.ok(fileExists('npm-debug.log'), 'npm-debug.log included')482 t.ok(fileExists('.npmrc'), '.npmrc included')483 t.ok(fileExists('.foo.swp'), '.foo.swp included')484 t.ok(fileExists('core'), 'core/ included')485 t.ok(fileExists('core/foo'), 'core/foo included')486 t.ok(fileExists('core/core'), 'core/core included')487 t.ok(fileExists('.DS_Store'), '.DS_Store included')488 t.ok(fileExists('._ohno'), '._ohno included')489 t.ok(fileExists('._ohnoes'), '._ohnoes included')490 t.ok(fileExists('foo.orig'), 'foo.orig included')491 t.ok(fileExists('package-lock.json'), 'package-lock.json included')492 done()493 })494})495test('certain files included unconditionally', function (t) {496 var fixture = new Tacks(497 Dir({498 'package.json': File({499 name: 'npm-test-files',500 version: '1.2.5'501 }),502 '.npmignore': File(503 'package.json',504 'README',505 'Readme',506 'readme.md',507 'readme.randomext',508 'changelog',509 'CHAngelog',510 'ChangeLOG.txt',511 'history',512 'HistorY',513 'HistorY.md',514 'license',515 'licence',516 'LICENSE',517 'LICENCE'518 ),519 'README': File(''),520 'Readme': File(''),521 'readme.md': File(''),522 'readme.randomext': File(''),523 'changelog': File(''),524 'CHAngelog': File(''),525 'ChangeLOG.txt': File(''),526 'history': File(''),527 'HistorY': File(''),528 'HistorY.md': File(''),529 'license': File(''),530 'licence': File(''),531 'LICENSE': File(''),532 'LICENCE': File('')533 })534 )535 withFixture(t, fixture, function (done) {536 t.ok(fileExists('package.json'), 'package.json included')537 t.ok(fileExists('README'), 'README included')538 t.ok(fileExists('Readme'), 'Readme included')539 t.ok(fileExists('readme.md'), 'readme.md included')540 t.ok(fileExists('readme.randomext'), 'readme.randomext included')541 t.ok(fileExists('changelog'), 'changelog included')542 t.ok(fileExists('CHAngelog'), 'CHAngelog included')543 t.ok(fileExists('ChangeLOG.txt'), 'ChangeLOG.txt included')544 t.ok(fileExists('license'), 'license included')545 t.ok(fileExists('licence'), 'licence included')546 t.ok(fileExists('LICENSE'), 'LICENSE included')547 t.ok(fileExists('LICENCE'), 'LICENCE included')548 done()549 })550})551test('unconditional inclusion does not capture modules', function (t) {552 var fixture = new Tacks(553 Dir({554 'package.json': File({555 name: 'npm-test-files',556 version: '1.2.5'557 }),558 'node_modules': Dir({559 'readme': Dir({ 'file': File('') }),560 'README': Dir({ 'file': File('') }),561 'licence': Dir({ 'file': File('') }),562 'license': Dir({ 'file': File('') }),563 'history': Dir({ 'file': File('') }),564 'History': Dir({ 'file': File('') }),565 'changelog': Dir({ 'file': File('') }),566 'ChangeLOG': Dir({ 'file': File('') })567 })568 })569 )570 withFixture(t, fixture, function (done) {571 t.notOk(fileExists('node_modules/readme/file'), 'readme module not included')572 t.notOk(fileExists('node_modules/README/file'), 'README module not included')573 t.notOk(fileExists('node_modules/licence/file'), 'licence module not included')574 t.notOk(fileExists('node_modules/license/file'), 'license module not included')575 t.notOk(fileExists('node_modules/history/file'), 'history module not included')576 t.notOk(fileExists('node_modules/History/file'), 'History module not included')577 t.notOk(fileExists('node_modules/changelog/file'), 'changelog module not included')578 t.notOk(fileExists('node_modules/ChangeLOG/file'), 'ChangeLOG module not included')579 done()580 })581})582test('folder-based inclusion works', function (t) {583 var fixture = new Tacks(584 Dir({585 'package.json': File({586 name: 'npm-test-files',587 version: '1.2.5',588 files: [589 'sub1/sub',590 'sub2'591 ]592 }),593 sub1: Dir({594 sub: Dir({595 include1: File(''),596 include2: File('')597 }),598 ignored: File('')599 }),600 sub2: Dir({601 include1: File(''),602 include2: File(''),603 empty: Dir({})604 })605 })606 )607 withFixture(t, fixture, function (done) {608 t.ok(fileExists('sub1/sub/include1'), 'nested dir included')609 t.ok(fileExists('sub1/sub/include2'), 'nested dir included')610 t.notOk(fileExists('sub1/ignored'), 'unspecified file not included')611 t.ok(fileExists('sub2/include1'), 'dir contents included')612 t.ok(fileExists('sub2/include2'), 'dir contents included')613 t.notOk(fileExists('sub2/empty'), 'empty dir not included')614 done()615 })616})617test('file that starts with @ sign included normally', (t) => {618 const fixture = new Tacks(619 Dir({620 'package.json': File({621 name: 'npm-test-files',622 version: '1.2.5'623 }),624 '@sub1': Dir({625 sub: Dir({626 include1: File('')627 })628 }),629 sub2: Dir({630 '@include': File(''),631 '@sub3': Dir({632 include1: File('')633 })634 })635 })636 )637 withFixture(t, fixture, function (done) {638 t.ok(fileExists('@sub1/sub/include1'), '@ dir included')639 t.ok(fileExists('sub2/@include'), '@ file included')640 t.ok(fileExists('sub2/@sub3/include1'), 'nested @ dir included')641 done()642 })643})644function fileExists (file) {645 try {646 return !!fs.statSync(path.resolve(targetpath, 'package', file))647 } catch (_) {648 return false649 }650}651function withFixture (t, fixture, tester) {652 fixture.create(fixturepath)653 mkdirp.sync(targetpath)654 common.npm(['pack', fixturepath], {cwd: basepath}, extractAndCheck)...

Full Screen

Full Screen

files-and-ignores.js

Source:files-and-ignores.js Github

copy

Full Screen

...29 notincluded: File('')30 })31 )32 withFixture(t, fixture, function (done) {33 t.ok(fileExists('include'), 'toplevel file included')34 t.ok(fileExists('sub/include'), 'nested file included')35 t.notOk(fileExists('notincluded'), 'unspecified file not included')36 done()37 })38})39test('basic file exclusion', function (t) {40 var fixture = new Tacks(41 Dir({42 'package.json': File({43 name: 'npm-test-files',44 version: '1.2.5'45 }),46 '.npmignore': File(47 'ignore\n' +48 'sub/ignore\n'49 ),50 include: File(''),51 ignore: File(''),52 sub: Dir({ ignore: File('') })53 })54 )55 withFixture(t, fixture, function (done) {56 t.notOk(fileExists('ignore'), 'toplevel file excluded')57 t.notOk(fileExists('sub/ignore'), 'nested file excluded')58 t.ok(fileExists('include'), 'unignored file included')59 done()60 })61})62test('toplevel-only and blanket ignores', function (t) {63 var fixture = new Tacks(64 Dir({65 'package.json': File({66 name: 'npm-test-files',67 version: '1.2.5'68 }),69 '.npmignore': File(70 './shallow1\n' +71 '/shallow2\n' +72 '/sub/onelevel\n' +73 'deep\n' +74 ''75 ),76 shallow1: File(''),77 shallow2: File(''),78 deep: File(''),79 sub: Dir({80 shallow1: File(''),81 shallow2: File(''),82 onelevel: File(''),83 deep: File(''),84 sub: Dir({85 deep: File(''),86 onelevel: File('')87 })88 })89 })90 )91 withFixture(t, fixture, function (done) {92 t.notOk(fileExists('shallow2'), '/ file excluded')93 t.ok(fileExists('sub/shallow1'), 'nested ./ file included')94 t.ok(fileExists('sub/shallow2'), 'nested / file included')95 t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')96 t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')97 t.notOk(fileExists('deep'), 'deep file excluded')98 t.notOk(fileExists('sub/deep'), 'nested deep file excluded')99 t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')100 t.ok(fileExists('shallow1'), './ file included')101 done()102 })103})104test('.npmignore works for nested directories recursively', function (t) {105 var fixture = new Tacks(106 Dir({107 'package.json': File({108 name: 'npm-test-files',109 version: '1.2.5'110 }),111 '.npmignore': File(112 '/ignore\n' +113 'deep\n'114 ),115 include: File(''),116 ignore: File(''),117 deep: File(''),118 sub: Dir({119 ignore: File(''),120 include: File(''),121 deep: File(''),122 sub: Dir({123 '.npmignore': File(124 '/ignore\n'125 ),126 ignore: File(''),127 include: File(''),128 deep: File('')129 })130 })131 })132 )133 withFixture(t, fixture, function (done) {134 t.notOk(fileExists('ignore'), 'toplevel file excluded')135 t.ok(fileExists('include'), 'unignored file included')136 t.ok(fileExists('sub/ignore'), 'same-name file in nested dir included')137 t.ok(fileExists('sub/include'), 'unignored nested dir file included')138 t.notOk(fileExists('sub/sub/ignore'), 'sub-sub-directory file excluded')139 t.ok(fileExists('sub/sub/include'), 'sub-sube-directory file included')140 t.notOk(fileExists('deep'), 'deep file excluded')141 t.notOk(fileExists('sub/deep'), 'sub-dir deep file excluded')142 t.notOk(fileExists('sub/sub/deep'), 'sub-sub-dir deep file excluded')143 done()144 })145})146test('.gitignore should have identical semantics', function (t) {147 var fixture = new Tacks(148 Dir({149 'package.json': File({150 name: 'npm-test-files',151 version: '1.2.5'152 }),153 '.gitignore': File(154 './shallow1\n' +155 '/shallow2\n' +156 '/sub/onelevel\n' +157 'deep\n' +158 ''159 ),160 shallow1: File(''),161 shallow2: File(''),162 deep: File(''),163 sub: Dir({164 shallow1: File(''),165 shallow2: File(''),166 onelevel: File(''),167 deep: File(''),168 sub: Dir({169 deep: File(''),170 onelevel: File('')171 })172 })173 })174 )175 withFixture(t, fixture, function (done) {176 t.notOk(fileExists('shallow2'), '/ file excluded')177 t.ok(fileExists('sub/shallow1'), 'nested ./ file included')178 t.ok(fileExists('sub/shallow2'), 'nested / file included')179 t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')180 t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')181 t.notOk(fileExists('deep'), 'deep file excluded')182 t.notOk(fileExists('sub/deep'), 'nested deep file excluded')183 t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')184 t.ok(fileExists('shallow1'), './ file included')185 done()186 })187})188test('.npmignore should always be overridden by files array', function (t) {189 var fixture = new Tacks(190 Dir({191 'package.json': File({192 name: 'npm-test-files',193 version: '1.2.5',194 files: [195 'include',196 'sub'197 ]198 }),199 '.npmignore': File(200 'include\n' +201 'ignore\n' +202 'sub/included\n'203 ),204 include: File(''),205 ignore: File(''),206 sub: Dir({207 include: File('')208 })209 })210 )211 withFixture(t, fixture, function (done) {212 t.notOk(fileExists('ignore'), 'toplevel file excluded')213 t.ok(fileExists('include'), 'unignored file included')214 t.ok(fileExists('sub/include'), 'nested file included')215 done()216 })217})218test('.gitignore supported for ignores', function (t) {219 var fixture = new Tacks(220 Dir({221 'package.json': File({222 name: 'npm-test-files',223 version: '1.2.5'224 }),225 '.gitignore': File(226 'ignore\n' +227 'sub/ignore\n'228 ),229 include: File(''),230 ignore: File(''),231 sub: Dir({ ignore: File('') })232 })233 )234 withFixture(t, fixture, function (done) {235 t.notOk(fileExists('ignore'), 'toplevel file excluded')236 t.notOk(fileExists('sub/ignore'), 'nested file excluded')237 t.ok(fileExists('include'), 'unignored file included')238 done()239 })240})241test('.npmignore completely overrides .gitignore', function (t) {242 var fixture = new Tacks(243 Dir({244 'package.json': File({245 name: 'npm-test-files',246 version: '1.2.5'247 }),248 '.npmignore': File(249 'ignore\n' +250 'sub/ignore\n'251 ),252 '.gitignore': File(253 'include\n' +254 'sub/include\n' +255 'extra\n'256 ),257 include: File(''),258 sub: Dir({ include: File('') }),259 extra: File('')260 })261 )262 withFixture(t, fixture, function (done) {263 t.ok(fileExists('include'), 'gitignored toplevel file included')264 t.ok(fileExists('extra'), 'gitignored extra toplevel file included')265 t.ok(fileExists('sub/include'), 'gitignored nested file included')266 t.notOk(fileExists('ignore'), 'toplevel file excluded')267 t.notOk(fileExists('sub/ignore'), 'nested file excluded')268 done()269 })270})271test('files array overrides .npmignore', function (t) {272 var fixture = new Tacks(273 Dir({274 'package.json': File({275 name: 'npm-test-files',276 version: '1.2.5',277 files: [278 'include',279 'sub/include'280 ]281 }),282 '.npmignore': File(283 'include\n' +284 'sub/include\n'285 ),286 include: File(''),287 sub: Dir({ include: File('') })288 })289 )290 withFixture(t, fixture, function (done) {291 t.ok(fileExists('include'), 'toplevel file included')292 t.ok(fileExists('sub/include'), 'nested file included')293 done()294 })295})296test('includes files regardless of emptiness', function (t) {297 var fixture = new Tacks(298 Dir({299 'package.json': File({300 name: 'npm-test-files',301 version: '1.2.5',302 files: [303 'full',304 'empty'305 ]306 }),307 full: File('This file has contents~'),308 empty: File('')309 })310 )311 withFixture(t, fixture, function (done) {312 t.ok(fileExists('full'), 'contentful file included')313 t.ok(fileExists('empty'), 'empty file included')314 done()315 })316})317test('.npmignore itself gets included', function (t) {318 var fixture = new Tacks(319 Dir({320 'package.json': File({321 name: 'npm-test-files',322 version: '1.2.5',323 files: [324 '.npmignore'325 ]326 }),327 '.npmignore': File('')328 })329 )330 withFixture(t, fixture, function (done) {331 t.ok(fileExists('.npmignore'), '.npmignore included')332 done()333 })334})335test('include default files when missing files spec', function (t) {336 var fixture = new Tacks(337 Dir({338 'package.json': File({339 name: 'npm-test-files',340 version: '1.2.5'341 }),342 'index.js': File(''),343 foo: File(''),344 node_modules: Dir({foo: Dir({bar: File('')})})345 })346 )347 withFixture(t, fixture, function (done) {348 t.ok(fileExists('index.js'), 'index.js included')349 t.ok(fileExists('foo'), 'foo included')350 t.notOk(fileExists('node_modules'), 'node_modules not included')351 done()352 })353})354test('include main file', function (t) {355 var fixture = new Tacks(356 Dir({357 'package.json': File({358 name: 'npm-test-files',359 version: '1.2.5',360 main: 'foo.js',361 files: []362 }),363 'index.js': File(''),364 'foo.js': File('')365 })366 )367 withFixture(t, fixture, function (done) {368 t.ok(fileExists('foo.js'), 'foo.js included because of main')369 t.notOk(fileExists('index.js'), 'index.js not included')370 done()371 })372})373test('certain files ignored unconditionally', function (t) {374 var fixture = new Tacks(375 Dir({376 'package.json': File({377 name: 'npm-test-files',378 version: '1.2.5',379 files: [380 '.git',381 '.svn',382 'CVS',383 '.hg',384 '.lock-wscript',385 '.wafpickle-0',386 '.wafpickle-5',387 '.wafpickle-50',388 'build/config.gypi',389 'npm-debug.log',390 '.npmrc',391 '.foo.swp',392 '.DS_Store',393 '._ohno',394 'foo.orig',395 'package-lock.json'396 ]397 }),398 '.git': Dir({foo: File('')}),399 '.svn': Dir({foo: File('')}),400 'CVS': Dir({foo: File('')}),401 '.hg': Dir({foo: File('')}),402 '.lock-wscript': File(''),403 '.wafpickle-0': File(''),404 '.wafpickle-5': File(''),405 '.wafpickle-50': File(''),406 'build': Dir({'config.gypi': File('')}),407 'npm-debug.log': File(''),408 '.npmrc': File(''),409 '.foo.swp': File(''),410 '.DS_Store': Dir({foo: File('')}),411 '._ohno': File(''),412 '._ohnoes': Dir({noes: File('')}),413 'foo.orig': File(''),414 'package-lock.json': File('')415 })416 )417 withFixture(t, fixture, function (done) {418 t.notOk(fileExists('.git'), '.git not included')419 t.notOk(fileExists('.svn'), '.svn not included')420 t.notOk(fileExists('CVS'), 'CVS not included')421 t.notOk(fileExists('.hg'), '.hg not included')422 t.notOk(fileExists('.lock-wscript'), '.lock-wscript not included')423 t.notOk(fileExists('.wafpickle-0'), '.wafpickle-0 not included')424 t.notOk(fileExists('.wafpickle-5'), '.wafpickle-5 not included')425 t.notOk(fileExists('.wafpickle-50'), '.wafpickle-50 not included')426 t.notOk(fileExists('build/config.gypi'), 'build/config.gypi not included')427 t.notOk(fileExists('npm-debug.log'), 'npm-debug.log not included')428 t.notOk(fileExists('.npmrc'), '.npmrc not included')429 t.notOk(fileExists('.foo.swp'), '.foo.swp not included')430 t.notOk(fileExists('.DS_Store'), '.DS_Store not included')431 t.notOk(fileExists('._ohno'), '._ohno not included')432 t.notOk(fileExists('._ohnoes'), '._ohnoes not included')433 t.notOk(fileExists('foo.orig'), 'foo.orig not included')434 t.notOk(fileExists('package-lock.json'), 'package-lock.json not included')435 done()436 })437})438test('certain files included unconditionally', function (t) {439 var fixture = new Tacks(440 Dir({441 'package.json': File({442 name: 'npm-test-files',443 version: '1.2.5'444 }),445 '.npmignore': File(446 'package.json',447 'README',448 'Readme',449 'readme.md',450 'readme.randomext',451 'changelog',452 'CHAngelog',453 'ChangeLOG.txt',454 'history',455 'HistorY',456 'HistorY.md',457 'license',458 'licence',459 'LICENSE',460 'LICENCE'461 ),462 'README': File(''),463 'Readme': File(''),464 'readme.md': File(''),465 'readme.randomext': File(''),466 'changelog': File(''),467 'CHAngelog': File(''),468 'ChangeLOG.txt': File(''),469 'history': File(''),470 'HistorY': File(''),471 'HistorY.md': File(''),472 'license': File(''),473 'licence': File(''),474 'LICENSE': File(''),475 'LICENCE': File('')476 })477 )478 withFixture(t, fixture, function (done) {479 t.ok(fileExists('package.json'), 'package.json included')480 t.ok(fileExists('README'), 'README included')481 t.ok(fileExists('Readme'), 'Readme included')482 t.ok(fileExists('readme.md'), 'readme.md included')483 t.ok(fileExists('readme.randomext'), 'readme.randomext included')484 t.ok(fileExists('changelog'), 'changelog included')485 t.ok(fileExists('CHAngelog'), 'CHAngelog included')486 t.ok(fileExists('ChangeLOG.txt'), 'ChangeLOG.txt included')487 t.ok(fileExists('license'), 'license included')488 t.ok(fileExists('licence'), 'licence included')489 t.ok(fileExists('LICENSE'), 'LICENSE included')490 t.ok(fileExists('LICENCE'), 'LICENCE included')491 done()492 })493})494test('unconditional inclusion does not capture modules', function (t) {495 var fixture = new Tacks(496 Dir({497 'package.json': File({498 name: 'npm-test-files',499 version: '1.2.5'500 }),501 'node_modules': Dir({502 'readme': Dir({ 'file': File('') }),503 'README': Dir({ 'file': File('') }),504 'licence': Dir({ 'file': File('') }),505 'license': Dir({ 'file': File('') }),506 'history': Dir({ 'file': File('') }),507 'History': Dir({ 'file': File('') }),508 'changelog': Dir({ 'file': File('') }),509 'ChangeLOG': Dir({ 'file': File('') })510 })511 })512 )513 withFixture(t, fixture, function (done) {514 t.notOk(fileExists('node_modules/readme/file'), 'readme module not included')515 t.notOk(fileExists('node_modules/README/file'), 'README module not included')516 t.notOk(fileExists('node_modules/licence/file'), 'licence module not included')517 t.notOk(fileExists('node_modules/license/file'), 'license module not included')518 t.notOk(fileExists('node_modules/history/file'), 'history module not included')519 t.notOk(fileExists('node_modules/History/file'), 'History module not included')520 t.notOk(fileExists('node_modules/changelog/file'), 'changelog module not included')521 t.notOk(fileExists('node_modules/ChangeLOG/file'), 'ChangeLOG module not included')522 done()523 })524})525test('folder-based inclusion works', function (t) {526 var fixture = new Tacks(527 Dir({528 'package.json': File({529 name: 'npm-test-files',530 version: '1.2.5',531 files: [532 'sub1/sub',533 'sub2'534 ]535 }),536 sub1: Dir({537 sub: Dir({538 include1: File(''),539 include2: File('')540 }),541 ignored: File('')542 }),543 sub2: Dir({544 include1: File(''),545 include2: File(''),546 empty: Dir({})547 })548 })549 )550 withFixture(t, fixture, function (done) {551 t.ok(fileExists('sub1/sub/include1'), 'nested dir included')552 t.ok(fileExists('sub1/sub/include2'), 'nested dir included')553 t.notOk(fileExists('sub1/ignored'), 'unspecified file not included')554 t.ok(fileExists('sub2/include1'), 'dir contents included')555 t.ok(fileExists('sub2/include2'), 'dir contents included')556 t.notOk(fileExists('sub2/empty'), 'empty dir not included')557 done()558 })559})560function fileExists (file) {561 try {562 return !!fs.statSync(path.resolve(targetpath, 'package', file))563 } catch (_) {564 return false565 }566}567function withFixture (t, fixture, tester) {568 fixture.create(fixturepath)569 mkdirp.sync(targetpath)570 common.npm(['pack', fixturepath], {cwd: basepath}, extractAndCheck)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fileExists } from 'storybook-root';2import { fileExists } from 'storybook-root';3import { fileExists } from 'storybook-root';4import { fileExists } from 'storybook-root';5import { fileExists } from 'storybook-root';6import { fileExists } from 'storybook-root';7import { fileExists } from 'storybook-root';8import { fileExists } from 'storybook-root';9import { fileExists } from 'storybook-root';10import { fileExists } from 'storybook-root';11import { fileExists } from 'storybook-root';12import { fileExists } from 'storybook-root';13import { fileExists } from 'storybook-root';14import { fileExists } from 'storybook-root';15import { fileExists } from 'storybook-root';16import { fileExists } from 'storybook-root';17import { fileExists } from 'storybook-root';18import { fileExists } from 'storybook-root';19import { fileExists } from 'storybook-root';20import { fileExists } from 'storybook-root';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fileExists } from 'storybook-root';2console.log(fileExists('test.js'));3import { fileExists } from 'storybook-root';4console.log(fileExists('test.js'));5import { fileExists } from 'storybook-root';6console.log(fileExists('test.js'));7import { fileExists } from 'storybook-root';8console.log(fileExists('test.js'));9import { fileExists } from 'storybook-root';10console.log(fileExists('test.js'));11import { fileExists } from 'storybook-root';12console.log(fileExists('test.js'));13import { fileExists } from 'storybook-root';14console.log(fileExists('test.js'));15import { fileExists } from 'storybook-root';16console.log(fileExists('test.js'));17import { fileExists } from 'storybook-root';18console.log(fileExists('test.js'));19import { fileExists } from 'storybook-root';20console.log(fileExists('test.js'));21import { fileExists } from 'storybook-root';22console.log(fileExists('test.js'));23import { fileExists } from 'storybook-root';24console.log(fileExists('test.js'));25import { fileExists } from 'storybook-root';26console.log(fileExists('test.js'));27import { fileExists } from 'storybook-root';28console.log(fileExists('test.js'));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fileExists } from 'storybook-root-addon';2import { addRoot } from 'storybook-root-addon';3import 'storybook-root-addon/register';4const { addRoot } = require('storybook-root-addon');5module.exports = (baseConfig, env, defaultConfig) => {6 return defaultConfig;7};8const { addRoot } = require('storybook-root-addon');9module.exports = {10 webpackFinal: (config) => {11 return config;12 },13};14const { addRoot } = require('storybook-root-addon');15module.exports = {16 webpackFinal: (config) => {17 return config;18 },19};20{21 "compilerOptions": {22 }23}24{25 "compilerOptions": {26 "paths": {

Full Screen

Using AI Code Generation

copy

Full Screen

1import {fileExists} from 'storybook-root/fileExists'2fileExists('./some/path')3import {fileExists} from 'storybook-root/fileExists'4import {fileExists} from './src/fileExists'5import {fileExists} from 'storybook-root/src/fileExists'6import {fileExists} from './fileExists'7import {fileExists} from 'storybook-root/src/fileExists'8import {fileExists} from './fileExists'9import {fileExists} from 'storybook-root/src/fileExists'10import {fileExists} from './fileExists'11import {fileExists} from 'storybook-root/src/fileExists'12import {fileExists} from './fileExists'13import {fileExists} from 'storybook-root/src/fileExists'14import {fileExists} from './fileExists'15import {fileExists} from 'storybook-root/src/fileExists'16import {fileExists} from './fileExists'17import {fileExists} from 'storybook-root/src/fileExists'18import {fileExists} from './fileExists'19import {fileExists} from 'storybook-root/src/fileExists'20import {fileExists} from './fileExists'21import {fileExists} from 'storybook-root/src/fileExists'22import {fileExists} from './fileExists'23import {fileExists} from 'storybook-root/src/fileExists'24import {fileExists} from './fileExists'25import {file

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 storybook-root 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