Skip to content

Commit ddf84b1

Browse files
committed
Merge branch 'fix-windows-enoent'
2 parents be1f3bf + 106af5a commit ddf84b1

File tree

5 files changed

+21
-47
lines changed

5 files changed

+21
-47
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"cosmiconfig": "^7.0.0",
3232
"exec-sh": "^0.4.0",
3333
"find-cache-dir": "^3.3.1",
34-
"fs-extra": "^10.0.0",
3534
"lodash": "^4.17.21",
3635
"npm-packlist": "^3.0.0",
3736
"pify": "^5.0.0",

pnpm-lock.yaml

Lines changed: 3 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dependency.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs');
12
const path = require('path');
23
const packlist = require('npm-packlist');
34
const tar = require('tar');
@@ -8,12 +9,12 @@ const { validate_path, promisified, default_ignore_rules, definitely_posix } = r
89
/**
910
*
1011
* @param relative_package_path {string}
11-
* @returns {Promise<{package_json_path: string, package_path: string, package_json_filename: string, package_json_content: *}>}
12+
* @returns {{package_json_path: string, package_path: string, package_json_filename: string, package_json_content: *}}
1213
*/
13-
async function get_package_details(relative_package_path) {
14+
function get_package_details(relative_package_path) {
1415
const package_path = path.resolve(relative_package_path);
1516

16-
if (!await promisified.fs.exists(package_path)) {
17+
if (!fs.existsSync(package_path)) {
1718
throw new Error(`Module '${relative_package_path}' was not found in '${path.resolve()}'.`);
1819
}
1920

@@ -42,11 +43,11 @@ async function get_ignore_file_rules(relative_package_path) {
4243

4344
try {
4445
// try to read .npmignore
45-
ignorefile = await promisified.fs.readFile(npmignorePath, 'utf-8');
46+
ignorefile = await fs.promises.readFile(npmignorePath, 'utf-8');
4647
} catch (e) {
4748
// .npmignore not found, try to read .gitignore
4849
try {
49-
ignorefile = await promisified.fs.readFile(gitignorePath, 'utf-8');
50+
ignorefile = await fs.promises.readFile(gitignorePath, 'utf-8');
5051
} catch (e) {
5152
// No ignore file found
5253
return [];
@@ -133,7 +134,7 @@ async function create_tarball({ name: local_dependency_name, version: local_depe
133134
throw new Error(`Could not pack module '${local_dependency_path}'`);
134135
}
135136

136-
if (!await promisified.fs.exists(tarball_path)) {
137+
if (!fs.existsSync(tarball_path)) {
137138
throw new Error(`Could not locate the created tarball '${tarball_name}' in '${temp_path}'.`);
138139
}
139140

@@ -179,7 +180,7 @@ async function install_tarball(tarball_name, { temp_path, cwd, manager = 'pnpm'
179180
async function delete_tarball(tarball_name, { temp_path }) {
180181
// console.log('delete_tarball', tarball_name);
181182
const tarball_path = path.resolve(temp_path, tarball_name);
182-
await promisified.fs.unlink(tarball_path);
183+
await fs.promises.unlink(tarball_path);
183184
}
184185

185186
module.exports = {

src/helpers.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
const path = require('path');
22
const fs = require('fs');
3-
const fse = require('fs-extra');
43
const pify = require('pify');
54
const rimraf = require('rimraf');
65

76
const promisified = {
8-
fs: {
9-
...pify(fs),
10-
exists: pify(fs.exists, { errorFirst: false }),
11-
},
12-
fse: pify(fse),
137
rimraf: pify(rimraf),
148
};
159

@@ -98,8 +92,8 @@ function color_log(msg, color) {
9892
* @param path {string}
9993
*/
10094
async function validate_path(path) {
101-
if (!await promisified.fs.exists(path)) {
102-
await promisified.fs.mkdir(path, { recursive: true });
95+
if (!fs.existsSync(path)) {
96+
await fs.promises.mkdir(path, { recursive: true });
10397
}
10498
}
10599

@@ -110,7 +104,7 @@ async function validate_path(path) {
110104
*/
111105
async function get_file_stats(file_path) {
112106
try {
113-
return await promisified.fse.lstat(file_path);
107+
return await fs.promises.lstat(file_path);
114108
} catch (e) {
115109
return null;
116110
}
@@ -138,12 +132,12 @@ async function copy_file_or_directory(source_path, destination_path) {
138132
const is_directory = stats.isDirectory();
139133

140134
if (is_directory) {
141-
return promisified.fs.mkdir(destination_path);
135+
return fs.promises.mkdir(destination_path);
142136
}
143137

144138
// console.log('COPY', source_path, 'to', destination_path);
145139

146-
return promisified.fse.copy(source_path, destination_path);
140+
return fs.promises.copyFile(source_path, destination_path);
147141
}
148142

149143
/**
@@ -152,7 +146,7 @@ async function copy_file_or_directory(source_path, destination_path) {
152146
* @returns {Promise<null|*>}
153147
*/
154148
async function detect_newline_at_eof(path) {
155-
const fileContents = await promisified.fs.readFile(path, 'utf-8');
149+
const fileContents = await fs.promises.readFile(path, 'utf-8');
156150

157151
const matches = fileContents.match(/\r?\n$/);
158152

src/project.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs');
12
const path = require('path');
23
const chokidar = require('chokidar');
34
const execSh = require('exec-sh').promise;
@@ -37,7 +38,7 @@ async function save_package_json(content, { cwd }) {
3738

3839
const newline_char = await detect_newline_at_eof(package_json_path);
3940

40-
promisified.fs.writeFile(package_json_path, JSON.stringify(content, null, 2) + newline_char);
41+
await fs.promises.writeFile(package_json_path, JSON.stringify(content, null, 2) + newline_char);
4142
}
4243

4344
/**
@@ -148,7 +149,7 @@ async function collect_dependencies_files(packed_dependencies, { cwd, modules_pa
148149
throw new Error('No data received to install the dependencies.');
149150
}
150151

151-
if (!await promisified.fs.exists(modules_path)) {
152+
if (!fs.existsSync(modules_path)) {
152153
throw new Error(`Could not find the modules directory. Tried: '${modules_path}'`);
153154
}
154155

@@ -157,7 +158,7 @@ async function collect_dependencies_files(packed_dependencies, { cwd, modules_pa
157158
const local_package_path = definitely_posix(path.resolve(cwd, local_dependency_path)); // source
158159
const installed_package_path = definitely_posix(path.resolve(modules_path, local_dependency_name)); // target
159160

160-
if (!await promisified.fs.exists(installed_package_path)) {
161+
if (!fs.existsSync(installed_package_path)) {
161162
throw new Error(`Could not find the installed package '${local_dependency_name}' in '${installed_package_path}'`);
162163
}
163164

0 commit comments

Comments
 (0)