{"size": 775, "ext": "js", "max_stars_repo_path": "packages/build/tests/utils/cache/fixtures/directory/plugin.js", "max_stars_repo_name": "sw-yx/build", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/build/tests/utils/cache/fixtures/directory/plugin.js", "max_issues_repo_name": "sw-yx/build", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/build/tests/utils/cache/fixtures/directory/plugin.js", "max_forks_repo_name": "sw-yx/build", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.724137931, "max_line_length": 54, "alphanum_fraction": 0.6735483871}
const { writeFile } = require('fs')
const { promisify } = require('util')

// eslint-disable-next-line node/no-extraneous-require
const del = require('del')
// eslint-disable-next-line node/no-extraneous-require
const pathExists = require('path-exists')
// eslint-disable-next-line node/no-extraneous-require
const makeDir = require('make-dir')

const pWriteFile = promisify(writeFile)

module.exports = {
  async onInit({ utils: { cache } }) {
    const id = String(Math.random()).replace('.', '')
    const dir = 'src'
    const path = `${dir}/${id}`

    await makeDir(dir)
    await pWriteFile(path, id)
    console.log(await cache.save(dir))
    await del(dir)

    console.log(await cache.restore(dir))
    console.log(await pathExists(path))
    await del(dir)
  },
}
