1 | ;
|
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 | */
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | exports.isEmptyDir = void 0;
|
12 | const fs_1 = require("fs");
|
13 | /**
|
14 | * Returns a boolean telling if a directory is empty or
|
15 | * not.
|
16 | */
|
17 | function 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 | }
|
26 | exports.isEmptyDir = isEmptyDir;
|