Skip to content

Commit e471fcb

Browse files
author
Alexander Krasnoyarov
committed
Initial release.
1 parent 34c8aea commit e471fcb

16 files changed

+724
-2
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
indent_size = 2
14+
trim_trailing_whitespace = false

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore

.gitattributes

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Autodetect text files
2+
* text=auto
3+
4+
# ...Unless the name matches the following overriding patterns
5+
6+
# Definitively text files
7+
.* text eol=lf
8+
*.php text eol=lf
9+
*.css text eol=lf
10+
*.js text eol=lf
11+
*.html text eol=lf
12+
*.json text eol=lf
13+
*.less text eol=lf
14+
*.scss text eol=lf
15+
*.sass text eol=lf
16+
*.txt text eol=lf
17+
*.md text eol=lf
18+
*.xml text eol=lf
19+
*.json text eol=lf
20+
*.bat text eol=lf
21+
*.svg text eol=lf
22+
*.sql text eol=lf
23+
*.xml text eol=lf
24+
*.yml text eol=lf
25+
26+
# Ensure those won't be messed up with
27+
*.ico binary
28+
*.png binary
29+
*.jpg binary
30+
*.jpeg binary
31+
*.webp binary
32+
*.gif binary
33+
*.eot binary
34+
*.ttf binary
35+
*.woff binary
36+
*.woff2 binary
37+
*.mp3 binary
38+
*.m4a binary
39+
*.mp4 binary
40+
*.m4p binary
41+
*.acc binary

.gitignore

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Logs
22
logs
3-
*.log
4-
npm-debug.log*
3+
*.log*
54

65
# Runtime data
76
pids
87
*.pid
98
*.seed
9+
*.lock
1010

1111
# Directory for instrumented libs generated by jscoverage/JSCover
1212
lib-cov
@@ -35,3 +35,16 @@ jspm_packages
3535

3636
# Optional REPL history
3737
.node_repl_history
38+
39+
# gitkeep
40+
!.gitkeep
41+
42+
# IDE
43+
.idea
44+
*.iml
45+
46+
#VSCode metadata
47+
.vscode
48+
49+
# Mac files
50+
.DS_Store

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- '6'
5+
- '5'
6+
- '4'
7+
cache:
8+
directories:
9+
- node_modules
10+
before_install:
11+
- npm prune
12+
- npm update

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 1.0.0
2+
3+
Initial release.

README.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# figlet-loader
2+
3+
[![NPM version](https://img.shields.io/npm/v/figlet-loader.svg)](https://www.npmjs.org/package/figlet-loader) [![Travis Build Status](https://img.shields.io/travis/itgalaxy/figlet-loader/master.svg?label=build)](https://travis-ci.org/itgalaxy/figlet-loader) [![dependencies Status](https://david-dm.org/itgalaxy/figlet-loader/status.svg)](https://david-dm.org/itgalaxy/figlet-loader) [![devDependencies Status](https://david-dm.org/itgalaxy/figlet-loader/dev-status.svg)](https://david-dm.org/itgalaxy/figlet-loader?type=dev)
4+
5+
## Installation
6+
7+
```shell
8+
$ npm install figlet-loader --save-dev
9+
```
10+
11+
## Initialization
12+
13+
You have to create a `.figletrc` configuration file and put your figlet stuff in it. Like so
14+
15+
```json
16+
// .figletrc or .figletrc.json
17+
{
18+
"options": {
19+
"outputTextBefore": "TEXT BEFORE",
20+
"outputTextBeforeEscape": true,
21+
"outputTextAfter": "TEXT AFTER",
22+
"outputTextAfterEscape": true,
23+
"font": "ANSI Shadow",
24+
"horizontalLayout": "default",
25+
"kerning": "default",
26+
"verticalLayout": "default"
27+
},
28+
"text": "ANOTHER-TEXT"
29+
}
30+
```
31+
32+
Full list of supported **"options"** and their **"description"** can be found in [figlet](https://github.com/patorjk/figlet.js).
33+
34+
### Webpack config
35+
36+
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
37+
38+
Put the following code to your webpack config file:
39+
40+
```javascript
41+
module.exports = {
42+
module: {
43+
loaders: [
44+
{
45+
loader: "figlet",
46+
test: /\.figletrc$/, // or "/\.figletrc\.json$/"
47+
}
48+
]
49+
},
50+
resolve: {
51+
alias: {
52+
figlet$: path.resolve(__dirname, "path/to/.figletrc") // or "path/to/.figletrc.json"
53+
}
54+
}
55+
}
56+
```
57+
58+
Using configuration through `resolve.alias` supported only `JSON` **(PR welcome)**.
59+
60+
Alternative configurations supported dynamic configuration:
61+
62+
```javascript
63+
module.exports = {
64+
module: {
65+
loaders: [
66+
{
67+
loader: `figlet?config=${encodeURI(JSON.stringify(figletConfig))}`,
68+
test: /figlet$/
69+
}
70+
]
71+
},
72+
resolve: {
73+
alias: {
74+
figlet$: path.resolve(__dirname, "path/to/empty-file") // You can add comment "Please do not delete this file" in this file
75+
}
76+
}
77+
}
78+
```
79+
80+
Using `config` through `query string` is have large priority than through `resolve.alias`.
81+
82+
Option `figletConfig` must contain `text` and `options` as above in **Initialization** section.
83+
84+
### Usage
85+
86+
Now you are able to import your custom figlet build as a module throughout your application like so:
87+
88+
```javscript
89+
import 'figlet';
90+
```
91+
92+
You can used [bundle](https://github.com/webpack/bundle-loader) plugin for async loading:
93+
94+
```javscript
95+
import 'bundle!figlet';
96+
```
97+
98+
## Related
99+
100+
- [figlet](https://github.com/patorjk/figlet.js) - API for this module
101+
102+
## Contribution
103+
104+
Don't hesitate to create a pull request. Every contribution is appreciated.
105+
106+
## [Changelog](CHANGELOG.md)
107+
108+
## [License](LICENSE.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"options": {
3+
"font": "NonexistsFont"
4+
},
5+
"text": "ANOTHER-TEXT"
6+
}

__tests__/fixtures/.figletrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"options": {
3+
"outputTextBefore": "TEXT BEFORE",
4+
"outputTextAfter": "TEXT AFTER",
5+
"font": "ANSI Shadow",
6+
"horizontalLayout": "default",
7+
"kerning": "default",
8+
"verticalLayout": "default"
9+
},
10+
"text": "ANOTHER-TEXT"
11+
}

__tests__/fixtures/.figletrc1.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"options": {
3+
"outputTextBefore": "TEXT BEFORE",
4+
"outputTextBeforeEscape": true,
5+
"outputTextAfter": "TEXT AFTER",
6+
"outputTextAfterEscape": true,
7+
"font": "ANSI Shadow",
8+
"horizontalLayout": "default",
9+
"kerning": "default",
10+
"verticalLayout": "default"
11+
},
12+
"text": "ANOTHER-TEXT"
13+
}

__tests__/fixtures/figlet.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Please do not delete this file */

__tests__/fixtures/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
require('./.figletrc.json');

__tests__/fixtures/index1.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
require('figlet');

0 commit comments

Comments
 (0)