Nuxt/test/utils/index.js

31 lines
902 B
JavaScript
Raw Normal View History

2018-10-24 13:53:34 +00:00
import klawSync from 'klaw-sync'
import got from 'got'
export { getNuxtConfig } from '../../packages/config'
2018-10-24 13:53:34 +00:00
export { default as getPort } from 'get-port'
2018-03-18 23:41:14 +00:00
2018-10-24 13:53:34 +00:00
export * from './nuxt'
export * from './resource-size'
export function listPaths (dir, pathsBefore = [], options = {}) {
if (Array.isArray(pathsBefore) && pathsBefore.length) {
2018-10-24 13:53:34 +00:00
// Only return files that didn't exist before building
// and files that have been changed
options.filter = (item) => {
2018-10-24 13:53:34 +00:00
const foundItem = pathsBefore.find((itemBefore) => {
return item.path === itemBefore.path
})
return typeof foundItem === 'undefined' ||
item.stats.mtimeMs !== foundItem.stats.mtimeMs
}
}
return klawSync(dir, options)
}
export function equalOrStartsWith (string1, string2) {
return string1 === string2 || string2.startsWith(string1)
}
export const rp = got.extend({ decompress: false })