mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #65647 Remove metalsmith types by @webketje
Metalsmith bundles types with its distribution since v2.6.0, see https://github.com/metalsmith/metalsmith/blob/v2.6.0/types/index.d.ts
This commit is contained in:
@@ -3285,6 +3285,10 @@
|
||||
"libraryName": "mermaid",
|
||||
"asOfVersion": "9.2.0"
|
||||
},
|
||||
"metalsmith": {
|
||||
"libraryName": "metalsmith",
|
||||
"asOfVersion": "2.6.0"
|
||||
},
|
||||
"metismenu": {
|
||||
"libraryName": "metismenu",
|
||||
"asOfVersion": "2.7.1"
|
||||
|
||||
365
types/metalsmith/index.d.ts
vendored
365
types/metalsmith/index.d.ts
vendored
@@ -1,365 +0,0 @@
|
||||
// Type definitions for metalsmith 2.3
|
||||
// Project: https://github.com/metalsmith/metalsmith
|
||||
// Definitions by: Brian Lagerman <https://github.com/brian-lagerman>, Kevin Van Lierde <https://github.com/webketje>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
/// <reference types="node" />
|
||||
import { Mode, Stats } from 'fs';
|
||||
interface Metalsmith {
|
||||
/**
|
||||
* Set the path of the `working` directory.
|
||||
* @param directory Relative or absolute `working` directory path.
|
||||
* @example
|
||||
* Set the relative `working` directory to './working'
|
||||
* Metalsmith(__dirname).directory("working");
|
||||
* @example
|
||||
* Set the absolute `working` directory to 'C:\Projects\Metalsmith\'
|
||||
* Metalsmith(__dirname).directory("C:\\Projects\\Metalsmith");
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#api
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L62
|
||||
*/
|
||||
directory(directory: string): Metalsmith;
|
||||
/**
|
||||
* Get the absolute path of the `working` directory
|
||||
* @example
|
||||
* Retrieve the absolute `working` directory path
|
||||
* const mwd:string = Metalsmith(__dirname).directory();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#api
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L62
|
||||
*/
|
||||
directory(): string;
|
||||
/**
|
||||
* Set the path of the `source` directory.
|
||||
* @param path [path='src'] - Relative or absolute `source` directory path.
|
||||
* @example
|
||||
* Set the relative `source` directory to './src' (the default)
|
||||
* Metalsmith(__dirname).source("src");
|
||||
* @example
|
||||
* Set the absolute `source` directory to 'C:\Projects\Site\'
|
||||
* Metalsmith(__dirname).source("C:\\\Projects\\\Site");
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#sourcepath
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L90
|
||||
*/
|
||||
source(path: string): Metalsmith;
|
||||
/**
|
||||
* Get the absolute path of the `source` directory.
|
||||
* @example
|
||||
* Retrieve the absolute `source` directory path
|
||||
* var src:string = Metalsmith(__dirname).source();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#sourcepath
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L90
|
||||
*/
|
||||
source(): string;
|
||||
/**
|
||||
* Set the path of the `destination` directory.
|
||||
* @param path [path='build'] - Relative or absolute `destination` directory path.
|
||||
* @example
|
||||
* Set the relative `destination` directory to './build' (the default)
|
||||
* Metalsmith(__dirname).destination("build");
|
||||
* @example
|
||||
* Set the absolute `destination` directory to 'C:\Projects\Out\'
|
||||
* Metalsmith(__dirname).destination("C:\\\Projects\\\Out");
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#destinationpath
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L104
|
||||
*/
|
||||
destination(path: string): Metalsmith;
|
||||
/**
|
||||
* Get the absolute path of the `destination` directory.
|
||||
* @example
|
||||
* Retrieve the absolute `destination` directory path
|
||||
* var dst:string = Metalsmith(__dirname).destination();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#destinationpath
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L104
|
||||
*/
|
||||
destination(): string;
|
||||
/**
|
||||
* Set the `maximum` number of files to open at once.
|
||||
* @param max [max=Infinity] - The `maximum` number of open files.
|
||||
* @example
|
||||
* Set the `maximum` number of files to open at once to 50
|
||||
* Metalsmith(__dirname).concurrency(50);
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#concurrencymax
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L118
|
||||
*/
|
||||
concurrency(max: number): Metalsmith;
|
||||
/**
|
||||
* Get the `maximum` number of files to open at once.
|
||||
* @example
|
||||
* Retrieve the `maximum` number of files to open at once
|
||||
* var max:number = Metalsmith(__dirname).concurrency();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#concurrencymax
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L118
|
||||
*/
|
||||
concurrency(): number;
|
||||
/**
|
||||
* Set whether the destination directory will be `cleaned` before writing.
|
||||
* @param clean [clean=true] - Flag to `clean` destination directory.
|
||||
* @example
|
||||
* Set the flag to `clean` the destination directory to false
|
||||
* Metalsmith(__dirname).clean(false);
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#cleanboolean
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L132
|
||||
*/
|
||||
clean(clean: boolean): Metalsmith;
|
||||
/**
|
||||
* Get the flag on whether the destination directory will be `cleaned` before writing.
|
||||
* @example
|
||||
* Retrieve the `clean` flag indicating destination directory removal
|
||||
* var clean:boolean = Metalsmith(__dirname).clean();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#cleanboolean
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L132
|
||||
*/
|
||||
clean(): boolean;
|
||||
/**
|
||||
* Set the flag on whether to parse YAML `frontmatter`
|
||||
* @param frontmatter [frontmatter=true] - Flag to parse YAML `frontmatter`.
|
||||
* @example
|
||||
* Set the flag to parse YAML `frontmatter` to false
|
||||
* Metalsmith(__dirname).frontmatter(false);
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#frontmatterboolean
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L145
|
||||
*/
|
||||
frontmatter(frontmatter: boolean): Metalsmith;
|
||||
/**
|
||||
* Get the flag on whether to parse YAML `frontmatter`
|
||||
* @example
|
||||
* Retrieve the `frontmatter` flag indicating YAML parsing
|
||||
* var parse:boolean = Metalsmith(__dirname).frontmatter();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#frontmatterboolean
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L145
|
||||
*/
|
||||
frontmatter(): boolean;
|
||||
/**
|
||||
* Set the global `metadata` object to pass to templates.
|
||||
* @param metadata - The global metadata (json).
|
||||
* @example
|
||||
* Add 'sitename' to the global `metadata` object
|
||||
* Metalsmith(__dirname).metadata({sitename: "My Static Site"});
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#metadatajson
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L76
|
||||
*/
|
||||
metadata(metadata: object): Metalsmith;
|
||||
/**
|
||||
* Get the global `metadata` object passed to templates.
|
||||
* @example
|
||||
* Retrieve the `metadata` object passed to templates
|
||||
* var meta:object = Metalsmith(__dirname).metadata();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#metadatajson
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L76
|
||||
*/
|
||||
metadata(): object;
|
||||
/**
|
||||
* Add a `plugin` function to the stack.
|
||||
* @param plugin - The plugin to add.
|
||||
* @example
|
||||
* Add 'metalsmith-markdown' to the middleware stack
|
||||
* Metalsmith(__dirname).use(markdown());
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#useplugin
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L50
|
||||
*/
|
||||
use(plugin: Metalsmith.Plugin | Metalsmith.Plugin[]): Metalsmith;
|
||||
/**
|
||||
* Set the `Ignore` files/paths from being loaded into Metalsmith.
|
||||
* @param files - The file(s) or directories to `ignore`.
|
||||
* @example
|
||||
* Add an `ignore` file to prevent load into Metalsmith
|
||||
* Metalsmith(__dirname).ignore("corrupted.html");
|
||||
* @example
|
||||
* Add an `ignore` function to prevent load into Metalsmith
|
||||
* Metalsmith(__dirname).ignore(ignore(function (filepath: string, stats: Stats) {
|
||||
* return stats.isDirectory() && path.basename(filepath) === 'nested';
|
||||
* });
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#ignorepath
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L159
|
||||
*/
|
||||
ignore(files: string | string[] | Metalsmith.Ignore | Metalsmith.Ignore[]): Metalsmith;
|
||||
/**
|
||||
* Get the array of `Ignored` files/paths.
|
||||
* @example
|
||||
* Retrieve the `ignored` array of files in Metalsmith
|
||||
* var ignored:string[] = Metalsmith(__dirname).ignore();
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#ignorepath
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L159
|
||||
*/
|
||||
ignore(): string[];
|
||||
/**
|
||||
* Resolve `paths` relative to the root directory.
|
||||
* @param paths - The `paths` to resolve.
|
||||
* @example
|
||||
* Retrieve the path after resolving sub-directies
|
||||
* var path:string = Metalsmith(__dirname).path("path-a", "path-b");
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#pathpaths
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L171
|
||||
*/
|
||||
path(...paths: string[]): string;
|
||||
/**
|
||||
* Perform the `build` with the current settings outputting to the destination directory.
|
||||
* @param fn - Optional **(but strongly encouraged)** {@link Callback} function.
|
||||
* @example
|
||||
* Perform the `build` with the current settings
|
||||
* Metalsmith(__dirname).build(
|
||||
* function (err: Error): any {
|
||||
* if (err) {throw err;}
|
||||
* });
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#buildfn
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L184
|
||||
*/
|
||||
build(fn?: Metalsmith.Callback): object;
|
||||
/**
|
||||
* `Process` files through plugins without writing out files.
|
||||
* @param fn - Optional Callback function.
|
||||
* @example
|
||||
* `Process` the files like `build` without writing any files
|
||||
* Metalsmith(__dirname).process(
|
||||
* function (err: Error): any {
|
||||
* if (err) {throw err;}
|
||||
* });
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#processfn
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L200
|
||||
*/
|
||||
process(fn?: Metalsmith.Callback): object;
|
||||
/**
|
||||
* `Run` a set of files through the plugins stack.
|
||||
* @param files - The dictionary of files.
|
||||
* @param fn - Optional Callback function.
|
||||
* @example
|
||||
* `Run` all of the middleware functions on a dictionary of files.
|
||||
* var callback:Metalsmith.Callback = (err: Error, files: object) => {if (err) {throw err;}};
|
||||
* Metalsmith(__dirname).run({fileA: "a.html"} , callback);
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#runfiles-fn
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L212
|
||||
*/
|
||||
run(files: object, fn?: Metalsmith.Callback): object;
|
||||
/**
|
||||
* `Run` a set of files through the plugins stack.
|
||||
* @param files - The dictionary of files.
|
||||
* @param fn - Optional Callback function.
|
||||
* @example
|
||||
* `Run` all of the middleware functions on a dictionary of files.
|
||||
* var callback:Metalsmith.Callback = (err: Error, files: object) => {if (err) {throw err;}};
|
||||
* Metalsmith(__dirname).run({fileA: "a.html"} , callback);
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#runfiles-fn
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L212
|
||||
*/
|
||||
run(files: object, plugins: Metalsmith.Plugin[], fn?: Metalsmith.Callback): object;
|
||||
/**
|
||||
* Read a dictionary of files from a `dir`, parsing frontmatter. If no directory
|
||||
* is provided, it will default to the source directory.
|
||||
* @param dir - Optional dictionary of files.
|
||||
* @example
|
||||
* Read a dictionary of files from a `dir`.
|
||||
* var files:object = Metalsmith(__dirname).read("subdir");
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L227
|
||||
*/
|
||||
read(dir: string, fn?: Metalsmith.Callback): object;
|
||||
/**
|
||||
* Read a dictionary of files from a `dir`, parsing frontmatter. If no directory
|
||||
* is provided, it will default to the source directory.
|
||||
* @param fn - Optional Callback function.
|
||||
* @example
|
||||
* Read a dictionary of files from a `dir`.
|
||||
* var files:object = Metalsmith(__dirname).read("subdir");
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L227
|
||||
*/
|
||||
read(fn: Metalsmith.Callback): object;
|
||||
/**
|
||||
* Read a `file` by path. If the path is not absolute, it will be resolved
|
||||
* relative to the source directory.
|
||||
* @param file - The file path.
|
||||
* @example
|
||||
* Read a `file` by path.
|
||||
* var fileData:object = Metalsmith(__dirname).readFile("a.html");
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L261
|
||||
*/
|
||||
readFile(file: string): object;
|
||||
/**
|
||||
* Write a dictionary of `files` to a destination `dir`. If no directory is
|
||||
* provided, it will default to the destination directory.
|
||||
* @param files - Dictionary of files.
|
||||
* @param dir - Optional destination directory.
|
||||
* @param fn - Optional Callback function.
|
||||
* @example
|
||||
* Write a dictionary of `files` to a destination `dir`.
|
||||
* Metalsmith(__dirname).write({fileA: "a.html"} , "C:\\\OutDir");
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L308
|
||||
*/
|
||||
write(files: object, dir?: string, fn?: Metalsmith.Callback): void;
|
||||
/**
|
||||
* Write a dictionary of `files` to a destination `dir`. If no directory is
|
||||
* provided, it will default to the destination directory.
|
||||
* @param files - Dictionary of files.
|
||||
* @param dir - Optional destination directory.
|
||||
* @example
|
||||
* Write a dictionary of `files` to a destination `dir`.
|
||||
* Metalsmith(__dirname).write({fileA: "a.html"} , "C:\\\OutDir");
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L308
|
||||
*/
|
||||
write(files: object, fn: Metalsmith.Callback): void;
|
||||
/**
|
||||
* Write a `file` by path with `data`. If the path is not absolute, it will be
|
||||
* resolved relative to the destination directory.
|
||||
* @param file - File path.
|
||||
* @param data - The file data.
|
||||
* @example
|
||||
* Write a `file` by path with `data`.
|
||||
* Metalsmith(__dirname).writeFile("test.html", {contents: "File Contents"});
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L336
|
||||
*/
|
||||
writeFile(file: string, data: object): void;
|
||||
|
||||
/**
|
||||
* The (read-only) list of plugins `use`'d by the current metalsmith instance.
|
||||
* When read from inside a plugin, the list is guaranteed to be complete
|
||||
*/
|
||||
readonly plugins: Metalsmith.Plugin[];
|
||||
|
||||
/**
|
||||
* The (read-only) list of ignores of the current metalsmith instance
|
||||
*/
|
||||
readonly ignores: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new `Metalsmith` builder with a working `directory`.
|
||||
* @param directory - The working directory.
|
||||
* @example
|
||||
* initialize Metalsmith with the node.js working directory
|
||||
* Metalsmith(__dirname);
|
||||
* @link [Metalsmith] http://www.metalsmith.io/
|
||||
* @link [API] https://github.com/metalsmith/metalsmith#new-metalsmithdir
|
||||
* @link [Source] https://github.com/metalsmith/metalsmith/blob/v2.3.0/lib/index.js#L30
|
||||
*/
|
||||
declare function Metalsmith(directory: string): Metalsmith;
|
||||
|
||||
declare namespace Metalsmith {
|
||||
/**
|
||||
* A Metalsmith plugin is a function that is passed the file list, the metalsmith instance, and a `done` callback.
|
||||
* Calling the callback is required for asynchronous plugins, and optional for synchronous plugins.
|
||||
*/
|
||||
type Plugin = (files: Files, metalsmith: Metalsmith, callback: Callback) => void;
|
||||
type Callback = (err: Error | null, files: Files, metalsmith: Metalsmith) => void;
|
||||
type Ignore = (path: string, stat: Stats) => void;
|
||||
|
||||
/**
|
||||
* Metalsmith representation of a file
|
||||
*/
|
||||
interface File {
|
||||
/** A Node {@link Buffer} that can be `.toString`'ed to obtain its human-readable contents */
|
||||
contents: Buffer;
|
||||
/** A Node {@link Stats} object with extra filesystem metadata and methods (like {@link Stats.isFile}) */
|
||||
stats?: Stats;
|
||||
/** Octal permission {@link Mode} of a file */
|
||||
mode?: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
/**
|
||||
* Metalsmith representation of the files in `metalsmith.source()`.
|
||||
* The keys represent the file paths and the values are {@link Metalsmith.File} objects
|
||||
*/
|
||||
interface Files {
|
||||
[filepath: string]: File;
|
||||
}
|
||||
}
|
||||
|
||||
export = Metalsmith;
|
||||
@@ -1,137 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
import * as Metalsmith from 'metalsmith';
|
||||
const collections = require('metalsmith-collections');
|
||||
const layouts = require('metalsmith-layouts');
|
||||
const markdown = require('metalsmith-markdown');
|
||||
const permalinks = require('metalsmith-permalinks');
|
||||
|
||||
// Well, here is our elevator pitch. It’s as easy as that:
|
||||
Metalsmith(__dirname) // __dirname defined by node.js:
|
||||
// name of current working directory
|
||||
.metadata({
|
||||
// add any variable you want
|
||||
// use them in layout-files
|
||||
sitename: 'My Static Site & Blog',
|
||||
siteurl: 'http://example.com/',
|
||||
description: "It's about saying »Hello« to the world.",
|
||||
generatorname: 'Metalsmith',
|
||||
generatorurl: 'http://metalsmith.io/',
|
||||
})
|
||||
.source('./src') // source directory
|
||||
.destination('./build') // destination directory
|
||||
.clean(true) // clean destination before
|
||||
.use(
|
||||
collections({
|
||||
// group all blog posts by internally
|
||||
posts: 'posts/*.md', // adding key 'collections':'posts'
|
||||
}),
|
||||
) // use `collections.posts` in layouts
|
||||
.use(markdown()) // transpile all md into html
|
||||
.use(
|
||||
permalinks({
|
||||
// change URLs to permalink URLs
|
||||
relative: false, // put css only in /css
|
||||
}),
|
||||
)
|
||||
.use(layouts()) // wrap layouts around html
|
||||
.build((err: Error | null) => {
|
||||
// build process
|
||||
if (err) throw err; // error handling is required
|
||||
});
|
||||
|
||||
// initialize via default export
|
||||
Metalsmith(__dirname);
|
||||
// initialize via default export with variable assignment
|
||||
const m = Metalsmith(__dirname);
|
||||
// set relative/absolute working directory
|
||||
Metalsmith(__dirname).directory('working');
|
||||
Metalsmith(__dirname).directory('C:\\Projects\\Metalsmith');
|
||||
// get absolute working directory
|
||||
const wrk = Metalsmith(__dirname).directory();
|
||||
// set relative/absolute source directory
|
||||
Metalsmith(__dirname).source('source');
|
||||
Metalsmith(__dirname).source('C:\\Projects\\Site');
|
||||
// get absolute source directory
|
||||
const src = Metalsmith(__dirname).source();
|
||||
// set relative/absolute destination directory
|
||||
Metalsmith(__dirname).destination('build');
|
||||
Metalsmith(__dirname).destination('C:\\Projects\\Out');
|
||||
// get absolute destination directory
|
||||
const dst = Metalsmith(__dirname).destination();
|
||||
// set max file concurrency
|
||||
Metalsmith(__dirname).concurrency(50);
|
||||
// get max file concurrency
|
||||
const max = Metalsmith(__dirname).concurrency();
|
||||
// set destination directory cleaning to false
|
||||
Metalsmith(__dirname).clean(false);
|
||||
// get destination directory cleaning flag
|
||||
const clean = Metalsmith(__dirname).clean();
|
||||
// set frontmatter parsing to false
|
||||
Metalsmith(__dirname).frontmatter(false);
|
||||
// get frontmatter parsing flag
|
||||
const parse = Metalsmith(__dirname).frontmatter();
|
||||
// set global metadata object
|
||||
Metalsmith(__dirname).metadata({ sitename: 'My Static Site' });
|
||||
// get global metadata object
|
||||
const meta = Metalsmith(__dirname).metadata();
|
||||
// plugin mock-up
|
||||
function fakePlugin(files: Metalsmith.Files, metalsmith: Metalsmith, done: any) {
|
||||
return;
|
||||
}
|
||||
// testing the file interface
|
||||
const file: Metalsmith.File = {
|
||||
contents: Buffer.from('string'),
|
||||
};
|
||||
// testing optional file properties
|
||||
file.mode;
|
||||
file.stats && file.stats.isSymbolicLink();
|
||||
// testing the files interface
|
||||
const files: Metalsmith.Files = {
|
||||
'path/to/file.js': file,
|
||||
};
|
||||
// testing files iteration & buffer toString
|
||||
Object.values(files).map(file => {
|
||||
return file.contents.toString();
|
||||
});
|
||||
Metalsmith(__dirname).ignores;
|
||||
// uncomment to test readonly protection
|
||||
// Metalsmith(__dirname).ignores = [];
|
||||
Metalsmith(__dirname).plugins;
|
||||
// uncomment to test readonly protection
|
||||
// Metalsmith(__dirname).plugins = [];
|
||||
// add a fakePlugin to the metalsmith pipeline
|
||||
Metalsmith(__dirname).use(fakePlugin);
|
||||
// add an ignore file
|
||||
Metalsmith(__dirname).ignore('corrupted.html');
|
||||
// get ignored files
|
||||
const ignored = Metalsmith(__dirname).ignore();
|
||||
// resolve "path-a" and "path-b" on working directory
|
||||
const path = Metalsmith(__dirname).path('path-a', 'path-b');
|
||||
// build without callback handler (not recommended, but allowed)
|
||||
Metalsmith(__dirname).build();
|
||||
const callback = (err: Error | null, files: Metalsmith.Files) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
// build with callback handler
|
||||
Metalsmith(__dirname).build(callback);
|
||||
// process without callback handler (not recommended, but allowed)
|
||||
Metalsmith(__dirname).process();
|
||||
// process with callback handler
|
||||
Metalsmith(__dirname).process((err: Error | null) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
// run with callback handler
|
||||
Metalsmith(__dirname).run({ fileA: 'a.html' }, callback);
|
||||
// read
|
||||
const filesData = Metalsmith(__dirname).read('subdir');
|
||||
// readFile
|
||||
const fileData = Metalsmith(__dirname).readFile('a.html');
|
||||
// write
|
||||
Metalsmith(__dirname).write({ fileA: 'a.html' }, 'C:\\OutDir');
|
||||
// writeFile
|
||||
Metalsmith(__dirname).writeFile('test.html', { contents: 'File Contents' });
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [ "../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"metalsmith-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "@definitelytyped/dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-var-requires": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user