UNPKG

645 BJavaScriptView Raw
1"use strict";
2/*
3 * @adonisjs/sink
4 *
5 * (c) Harminder Virk <virk@adonisjs.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10Object.defineProperty(exports, "__esModule", { value: true });
11exports.isEmptyDir = void 0;
12const fs_1 = require("fs");
13/**
14 * Returns a boolean telling if a directory is empty or
15 * not.
16 */
17function isEmptyDir(location) {
18 try {
19 const files = (0, fs_1.readdirSync)(location);
20 return files.length === 0;
21 }
22 catch (error) {
23 return error.code === 'ENOENT';
24 }
25}
26exports.isEmptyDir = isEmptyDir;