mirror of
https://github.com/Leaflet/Leafdoc.git
synced 2025-07-26 08:41:43 +00:00
Replace 'sander' dependency with 'fs'. (#48)
This commit is contained in:
@ -14,7 +14,6 @@
|
|||||||
"handlebars": "^4.0.11",
|
"handlebars": "^4.0.11",
|
||||||
"marked": "^0.3.12",
|
"marked": "^0.3.12",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"sander": "^0.6.0",
|
|
||||||
"unicode-7.0.0": "^0.1.5",
|
"unicode-7.0.0": "^0.1.5",
|
||||||
"xregexp": "^2.0.0"
|
"xregexp": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
@ -25,7 +25,7 @@ export default [
|
|||||||
// builtins(),
|
// builtins(),
|
||||||
// globals()
|
// globals()
|
||||||
],
|
],
|
||||||
external: ['sander', 'path']
|
external: ['fs', 'path']
|
||||||
},
|
},
|
||||||
|
|
||||||
// CommonJS (for Node) and ES module (for bundlers) build.
|
// CommonJS (for Node) and ES module (for bundlers) build.
|
||||||
@ -46,7 +46,7 @@ export default [
|
|||||||
// resolve(), // so Rollup can find `crc32`
|
// resolve(), // so Rollup can find `crc32`
|
||||||
// commonjs() // so Rollup can convert `crc32` to an ES module
|
// commonjs() // so Rollup can convert `crc32` to an ES module
|
||||||
],
|
],
|
||||||
external: ['sander', 'path']
|
external: ['fs', 'path']
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -65,6 +65,6 @@ export default [
|
|||||||
// resolve(), // so Rollup can find `crc32`
|
// resolve(), // so Rollup can find `crc32`
|
||||||
// commonjs() // so Rollup can convert `crc32` to an ES module
|
// commonjs() // so Rollup can convert `crc32` to an ES module
|
||||||
],
|
],
|
||||||
external: ['sander', 'path']
|
external: ['fs', 'path']
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
11
src/cli.js
11
src/cli.js
@ -15,11 +15,10 @@ Leafdoc includes a small command-line utility, useful when running from a consol
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var fs = require("fs");
|
||||||
var minimist = require('minimist');
|
|
||||||
var sander = require('sander');
|
|
||||||
var Leafdoc = require('./leafdoc');
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var minimist = require('minimist');
|
||||||
|
var Leafdoc = require('./leafdoc');
|
||||||
|
|
||||||
var argv = minimist(process.argv.slice(2), {
|
var argv = minimist(process.argv.slice(2), {
|
||||||
alias: {
|
alias: {
|
||||||
@ -52,7 +51,7 @@ var doc = new Leafdoc({
|
|||||||
|
|
||||||
argv._.forEach(function (filepath) {
|
argv._.forEach(function (filepath) {
|
||||||
try {
|
try {
|
||||||
var stats = sander.statSync(filepath);
|
var stats = fs.lstatSync(filepath);
|
||||||
|
|
||||||
if (stats.isFile()) {
|
if (stats.isFile()) {
|
||||||
doc.addFile(filepath, path.extname(filepath) !== '.leafdoc');
|
doc.addFile(filepath, path.extname(filepath) !== '.leafdoc');
|
||||||
@ -74,7 +73,7 @@ if (argv.json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argv.output) {
|
if (argv.output) {
|
||||||
sander.writeFileSync(argv.output, out);
|
fs.writeFileSync(argv.output, out);
|
||||||
} else {
|
} else {
|
||||||
console.log(out);
|
console.log(out);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
import sander from 'sander';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import {getTemplate, setTemplateDir, setAKAs} from './template';
|
import {getTemplate, setTemplateDir, setAKAs} from './template';
|
||||||
@ -158,13 +158,13 @@ Leafdoc.prototype.addDir = function (dirname, extensions) {
|
|||||||
extensions = ['.js', '.leafdoc'];
|
extensions = ['.js', '.leafdoc'];
|
||||||
}
|
}
|
||||||
|
|
||||||
var filenames = sander.readdirSync(dirname);
|
var filenames = fs.readdirSync(dirname);
|
||||||
|
|
||||||
for (var i in filenames) {
|
for (var i in filenames) {
|
||||||
var filename = path.join(dirname, filenames[i]);
|
var filename = path.join(dirname, filenames[i]);
|
||||||
// Check if dir, recurse if so
|
// Check if dir, recurse if so
|
||||||
|
|
||||||
var stats = sander.statSync(filename);
|
var stats = fs.lstatSync(filename);
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
this.addDir(filename, extensions);
|
this.addDir(filename, extensions);
|
||||||
} else if (extensions.indexOf(path.extname(filename)) !== -1) {
|
} else if (extensions.indexOf(path.extname(filename)) !== -1) {
|
||||||
@ -182,7 +182,7 @@ Leafdoc.prototype.addDir = function (dirname, extensions) {
|
|||||||
// 🍂method addFile(filename: String, isSource?: Boolean): this
|
// 🍂method addFile(filename: String, isSource?: Boolean): this
|
||||||
// Parses the given file using [`addBuffer`](#leafdoc-addbuffer).
|
// Parses the given file using [`addBuffer`](#leafdoc-addbuffer).
|
||||||
Leafdoc.prototype.addFile = function (filename, isSource) {
|
Leafdoc.prototype.addFile = function (filename, isSource) {
|
||||||
return this.addBuffer(sander.readFileSync(filename), isSource);
|
return this.addBuffer(fs.readFileSync(filename), isSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Minor wrapper over Handlebars
|
// Minor wrapper over Handlebars
|
||||||
|
|
||||||
import sander from 'sander';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
import marked from 'marked';
|
import marked from 'marked';
|
||||||
@ -17,7 +17,7 @@ export function setTemplateDir(newDir) {
|
|||||||
|
|
||||||
export function getTemplate(templateName) {
|
export function getTemplate(templateName) {
|
||||||
if (!templates[templateName]) {
|
if (!templates[templateName]) {
|
||||||
templates[templateName] = Handlebars.compile(sander.readFileSync(templateDir, templateName + '.hbs').toString());
|
templates[templateName] = Handlebars.compile(fs.readFileSync(path.join(templateDir, templateName + '.hbs')).toString());
|
||||||
}
|
}
|
||||||
return templates[templateName];
|
return templates[templateName];
|
||||||
}
|
}
|
||||||
|
6
test.js
6
test.js
@ -13,6 +13,6 @@ doc.addDir('src');
|
|||||||
var out = doc.outputStr();
|
var out = doc.outputStr();
|
||||||
var json = doc.outputJSON();
|
var json = doc.outputJSON();
|
||||||
|
|
||||||
var sander = require('sander');
|
var fs = require('fs');
|
||||||
sander.writeFileSync('Leafdoc.html', out);
|
fs.writeFileSync('Leafdoc.html', out);
|
||||||
sander.writeFileSync('Leafdoc.json', json);
|
fs.writeFileSync('Leafdoc.json', json);
|
||||||
|
Reference in New Issue
Block a user