support fs.readdir and fs.readdirSync
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- build-system
Hướng nghiên cứu
Sử dụng các ví dụ trong controllers/index.js và app.js làm tham chiếu về hành vi, sau đó xem xét cách brfs hiện xử lý fs.readFileSync. Làm rõ liệu mục tiêu là mở rộng tĩnh fs.readdir và fs.readdirSync, các mẫu require động hay cả hai; trạng thái hoàn tất cần bao gồm hành vi chuyển đổi được xác định và độ bao phủ cho các trường hợp được hỗ trợ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I think this is feasible, and I personally think this is really useful.
In node.js it's reasonably common for me to do things like:
// controllers/index.js
'use strict';
var fs = require('fs');
var path = require('path');
var ROOT_PATH = __dirname;
module.exports = function(path) {
var fnames = fs.readdirSync(ROOT_PATH);
var paths = fnames.map(function(fname) {
return path.join(ROOT_PATH, fname, '.js');
});
var modules = paths.map(function(path) {
return require(path);
});
return modules.map(function(module) {
// do something with the module
// i.e. if it's this is a mongoose schema bootstrapping utility, register the model.
// if this is a express controller bootstrapping utility, parse its methods and register
// matching routes.
// etc.
});
};
This allows us to abstract whole parts of the code, later on - even treat them as completely separate modules:
// app.js
var controllers = require('./controllers')
// bootstrap the controllers
controllers(/* something would come here such as an express app or a mongoose.Connection */);
If we could do this with browserify, things like bootstrapping an Ember app, could be automated. I know there are a couple of problems.
Here's an analogous example that works, though not exactly as one would hope it'd.
I know this has to do with limitations on the browserify module (which may be impossible to address) but this would be really cool.
Perhaps we could even parse things like:
['./a', './b'].map(function(name) {
return require(name);
});
Into:
[require('./a'), require('./b')];
Or provide an utility requireMap thing that resolved into that.
I don't know if this is a relevant issue. But I though this would be a nice thing, if it was possible.
At it's core, the main point was simply to add:
var fs = require('fs');
var files = fs.readdirSync('.');
To be transformed into:
var fs = require('fs');
var files = ['a.js', 'b.js', 'main.js' /* etc. */];
What do you think?
- Ngôn ngữ chính
- JavaScript
- Star
- 556
- Fork
- 58
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của browserify/brfs
-
Deprecation on sourcemap-codecĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
browserify/brfs#100 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
browserify/brfs#99 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
browserify/brfs#97 ·
-
Bug in merged source mapsĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
browserify/brfs#86 · 3 bình luận ·
-
include `fs.statSync`/`fs.stat`?Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
browserify/brfs#80 · 1 bình luận ·
Tất cả issue của browserify/brfs
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
LucasSantana-Dev/Lucky#2945 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
brijeshb42/monaco-vim#175 ·
-
good first issue
Độ khó 2/5 3-5 ngày Mức phù hợp với người mới 62/100
paipai1999/POS-system#3 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MikeMcl/bignumber.js#418 ·