import all from 'funko/lib/future/all' import cacheFuture from 'funko/lib/future/cache' import close from './close.test' import expect from 'must' import fstat from './fstat' import open from './open.test' import testFile from '../test/test-file' import wrapCatchable from 'funko/lib/future/wrap-catchable' export default cacheFuture( all([ open, close, testFile(__filename) ]) // Future Error [ Module ] .chain(([ open, close, path ]) => open(null, 'r+', path) // Future Error FileDescriptor .chain(fd => fstat(fd) // Future Error Stat .chain(wrapCatchable(stat => { expect(stat).to.be.an.object() return close(fd) })) // Future Error FileDescriptor ) // Future Error FileDescriptor .map(() => fstat) // Future Error Module ) )
}) } }) } } function transformFiles(pattern, transformer) { return glob({ dot: true }, pattern) .chain(pipe([ map(createFileTransformer(transformer)), all ])) } all([ transformFiles('{,{src,test,tools}/**/}{.babelrc,*.json}', sortJson), transformFiles('{,{src,test,tools}/**/}{.gitignore,.npmignore}', sortLines) ]).fork( error => { process.exitCode = 1 log.error(error) }, ([ json, lines ]) => { const changed = json.concat(lines).filter(path => path !== null) if (changed.length > 0) { if (ERROR_ON_CHANGES) process.exitCode = 1 logErrorOrInfo(`Sorted configuration files, updated ${changed.length} file${changed.length > 1 ? 's': ''}.`) } else { log.info('Sorted configuration files, no changes.') } } )