Skip to content

Commit

Permalink
style: line break
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Oct 14, 2019
1 parent 6dbe283 commit 4633bfb
Show file tree
Hide file tree
Showing 154 changed files with 6,468 additions and 6,466 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
12 changes: 6 additions & 6 deletions eslint.release.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const config = require('./eslint.src');

config.globals = {};
(config.rules['no-var'] = 'off'), (config.rules['prefer-const'] = 'off');

module.exports = config;
const config = require('./eslint.src');

config.globals = {};
(config.rules['no-var'] = 'off'), (config.rules['prefer-const'] = 'off');

module.exports = config;
40 changes: 20 additions & 20 deletions lib/setup.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const fs = require('fs');
const path = require('path');
const execa = require('execa');

const pkg = require('../package.json');
const pkgPath = path.resolve(__dirname, '../package.json');

writePkgName('licia-src');

execa('npm', ['i', 'licia'], {
cwd: path.resolve(__dirname, '../'),
stdio: 'inherit'
}).then(() => {
writePkgName('licia');
});

function writePkgName(name) {
pkg.name = name;
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf8');
}
const fs = require('fs');
const path = require('path');
const execa = require('execa');

const pkg = require('../package.json');
const pkgPath = path.resolve(__dirname, '../package.json');

writePkgName('licia-src');

execa('npm', ['i', 'licia'], {
cwd: path.resolve(__dirname, '../'),
stdio: 'inherit'
}).then(() => {
writePkgName('licia');
});

function writePkgName(name) {
pkg.name = name;
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf8');
}
104 changes: 52 additions & 52 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
const { rmdir, promisify, mkdir, fs, rpad, ansiColor } = require('licia');
const execa = require('execa');
const glob = require('glob');
const ncp = require('ncp');
const path = require('path');
const handlebars = require('handlebars');
const eustia = require('eustia');

const regStartOneSpace = /^ /gm;

exports.outdentOneSpace = function(data) {
return data.replace(regStartOneSpace, '');
};

exports.rmdir = promisify(rmdir);
exports.glob = promisify(glob);
exports.mkdir = promisify(mkdir);
exports.cpFile = promisify(ncp);

exports.fileExist = async function(path) {
const exist = await fs.exists(path);
if (!exist) throw Error(path + " doesn't not exist.");
};

exports.readTpl = async function(name, cb) {
const data = await fs.readFile(
path.resolve(__dirname, './tpl/' + name + '.hbs'),
'utf-8'
);

return handlebars.compile(data, { noEscape: true });
};

handlebars.registerHelper('rapd', function(len, ctx) {
return rpad(ctx.fn(this), +len, ' ');
});
['yellow', 'green', 'cyan', 'red', 'white', 'magenta'].forEach(function(color) {
handlebars.registerHelper(color, function(ctx) {
return ansiColor[color](ctx.fn(this));
});
});

exports.eustiaBuild = promisify(eustia.build);
exports.eustiaDoc = promisify(eustia.doc);

exports.runScript = function(name, args) {
return execa(name, args, {
preferLocal: true,
cwd: path.resolve(__dirname, '../'),
stdio: 'inherit'
});
};
const { rmdir, promisify, mkdir, fs, rpad, ansiColor } = require('licia');
const execa = require('execa');
const glob = require('glob');
const ncp = require('ncp');
const path = require('path');
const handlebars = require('handlebars');
const eustia = require('eustia');

const regStartOneSpace = /^ /gm;

exports.outdentOneSpace = function(data) {
return data.replace(regStartOneSpace, '');
};

exports.rmdir = promisify(rmdir);
exports.glob = promisify(glob);
exports.mkdir = promisify(mkdir);
exports.cpFile = promisify(ncp);

exports.fileExist = async function(path) {
const exist = await fs.exists(path);
if (!exist) throw Error(path + " doesn't not exist.");
};

exports.readTpl = async function(name, cb) {
const data = await fs.readFile(
path.resolve(__dirname, './tpl/' + name + '.hbs'),
'utf-8'
);

return handlebars.compile(data, { noEscape: true });
};

handlebars.registerHelper('rapd', function(len, ctx) {
return rpad(ctx.fn(this), +len, ' ');
});
['yellow', 'green', 'cyan', 'red', 'white', 'magenta'].forEach(function(color) {
handlebars.registerHelper(color, function(ctx) {
return ansiColor[color](ctx.fn(this));
});
});

exports.eustiaBuild = promisify(eustia.build);
exports.eustiaDoc = promisify(eustia.doc);

exports.runScript = function(name, args) {
return execa(name, args, {
preferLocal: true,
cwd: path.resolve(__dirname, '../'),
stdio: 'inherit'
});
};
9 changes: 5 additions & 4 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
singleQuote: true,
tabWidth: 4
};
module.exports = {
singleQuote: true,
tabWidth: 4,
endOfLine: 'lf'
};
220 changes: 110 additions & 110 deletions src/a/ansiColor.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,110 @@
/* Ansi colors.
*
* ### Available colors
*
* black, red, green, yellow, blue, magenta, cyan, white, gray, grey
*
* bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite,
*
* blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright
*
* bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright
*/

/* example
* ansiColor.red('Warning');
*/

/* module
* env: node
* test: manual
* since: 1.4.1
*/

/* typescript
* export declare namespace ansiColor {
* interface IFn {
* (str: string): string;
* }
* }
* export declare const ansiColor: {
* black: ansiColor.IFn;
* red: ansiColor.IFn;
* green: ansiColor.IFn;
* yellow: ansiColor.IFn;
* blue: ansiColor.IFn;
* magenta: ansiColor.IFn;
* cyan: ansiColor.IFn;
* white: ansiColor.IFn;
* gray: ansiColor.IFn;
* grey: ansiColor.IFn;
* bgBlack: ansiColor.IFn;
* bgRed: ansiColor.IFn;
* bgGreen: ansiColor.IFn;
* bgYellow: ansiColor.IFn;
* bgBlue: ansiColor.IFn;
* bgMagenta: ansiColor.IFn;
* bgCyan: ansiColor.IFn;
* bgWhite: ansiColor.IFn;
* blackBright: ansiColor.IFn;
* redBright: ansiColor.IFn;
* greenBright: ansiColor.IFn;
* yellowBright: ansiColor.IFn;
* blueBright: ansiColor.IFn;
* magentaBright: ansiColor.IFn;
* cyanBright: ansiColor.IFn;
* whiteBright: ansiColor.IFn;
* bgBlackBright: ansiColor.IFn;
* bgRedBright: ansiColor.IFn;
* bgGreenBright: ansiColor.IFn;
* bgYellowBright: ansiColor.IFn;
* bgBlueBright: ansiColor.IFn;
* bgMagentaBright: ansiColor.IFn;
* bgCyanBright: ansiColor.IFn;
* bgWhiteBright: ansiColor.IFn;
* }
*/

exports = {
black: genColor([0, 0]),
red: genColor([31, 39]),
green: genColor([32, 39]),
yellow: genColor([33, 39]),
blue: genColor([34, 39]),
magenta: genColor([35, 39]),
cyan: genColor([36, 39]),
white: genColor([37, 39]),
gray: genColor([90, 39]),
grey: genColor([90, 39]),
bgBlack: genColor([40, 49]),
bgRed: genColor([41, 49]),
bgGreen: genColor([42, 49]),
bgYellow: genColor([43, 49]),
bgBlue: genColor([44, 49]),
bgMagenta: genColor([45, 49]),
bgCyan: genColor([46, 49]),
bgWhite: genColor([47, 49]),
blackBright: genColor([90, 39]),
redBright: genColor([91, 39]),
greenBright: genColor([92, 39]),
yellowBright: genColor([93, 39]),
blueBright: genColor([94, 39]),
magentaBright: genColor([95, 39]),
cyanBright: genColor([96, 39]),
whiteBright: genColor([97, 39]),
bgBlackBright: genColor([100, 49]),
bgRedBright: genColor([101, 49]),
bgGreenBright: genColor([102, 49]),
bgYellowBright: genColor([103, 49]),
bgBlueBright: genColor([104, 49]),
bgMagentaBright: genColor([105, 49]),
bgCyanBright: genColor([106, 49]),
bgWhiteBright: genColor([107, 49])
};

function genColor(codes) {
const open = `\u001b[${codes[0]}m`;
const close = `\u001b[${codes[1]}m`;

return input => open + input + close;
}
/* Ansi colors.
*
* ### Available colors
*
* black, red, green, yellow, blue, magenta, cyan, white, gray, grey
*
* bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite,
*
* blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright
*
* bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright
*/

/* example
* ansiColor.red('Warning');
*/

/* module
* env: node
* test: manual
* since: 1.4.1
*/

/* typescript
* export declare namespace ansiColor {
* interface IFn {
* (str: string): string;
* }
* }
* export declare const ansiColor: {
* black: ansiColor.IFn;
* red: ansiColor.IFn;
* green: ansiColor.IFn;
* yellow: ansiColor.IFn;
* blue: ansiColor.IFn;
* magenta: ansiColor.IFn;
* cyan: ansiColor.IFn;
* white: ansiColor.IFn;
* gray: ansiColor.IFn;
* grey: ansiColor.IFn;
* bgBlack: ansiColor.IFn;
* bgRed: ansiColor.IFn;
* bgGreen: ansiColor.IFn;
* bgYellow: ansiColor.IFn;
* bgBlue: ansiColor.IFn;
* bgMagenta: ansiColor.IFn;
* bgCyan: ansiColor.IFn;
* bgWhite: ansiColor.IFn;
* blackBright: ansiColor.IFn;
* redBright: ansiColor.IFn;
* greenBright: ansiColor.IFn;
* yellowBright: ansiColor.IFn;
* blueBright: ansiColor.IFn;
* magentaBright: ansiColor.IFn;
* cyanBright: ansiColor.IFn;
* whiteBright: ansiColor.IFn;
* bgBlackBright: ansiColor.IFn;
* bgRedBright: ansiColor.IFn;
* bgGreenBright: ansiColor.IFn;
* bgYellowBright: ansiColor.IFn;
* bgBlueBright: ansiColor.IFn;
* bgMagentaBright: ansiColor.IFn;
* bgCyanBright: ansiColor.IFn;
* bgWhiteBright: ansiColor.IFn;
* }
*/

exports = {
black: genColor([0, 0]),
red: genColor([31, 39]),
green: genColor([32, 39]),
yellow: genColor([33, 39]),
blue: genColor([34, 39]),
magenta: genColor([35, 39]),
cyan: genColor([36, 39]),
white: genColor([37, 39]),
gray: genColor([90, 39]),
grey: genColor([90, 39]),
bgBlack: genColor([40, 49]),
bgRed: genColor([41, 49]),
bgGreen: genColor([42, 49]),
bgYellow: genColor([43, 49]),
bgBlue: genColor([44, 49]),
bgMagenta: genColor([45, 49]),
bgCyan: genColor([46, 49]),
bgWhite: genColor([47, 49]),
blackBright: genColor([90, 39]),
redBright: genColor([91, 39]),
greenBright: genColor([92, 39]),
yellowBright: genColor([93, 39]),
blueBright: genColor([94, 39]),
magentaBright: genColor([95, 39]),
cyanBright: genColor([96, 39]),
whiteBright: genColor([97, 39]),
bgBlackBright: genColor([100, 49]),
bgRedBright: genColor([101, 49]),
bgGreenBright: genColor([102, 49]),
bgYellowBright: genColor([103, 49]),
bgBlueBright: genColor([104, 49]),
bgMagentaBright: genColor([105, 49]),
bgCyanBright: genColor([106, 49]),
bgWhiteBright: genColor([107, 49])
};

function genColor(codes) {
const open = `\u001b[${codes[0]}m`;
const close = `\u001b[${codes[1]}m`;

return input => open + input + close;
}
Loading

0 comments on commit 4633bfb

Please sign in to comment.