mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-17 14:30:34 +08:00
feat(cli): do not print in color in netlify builds
This commit is contained in:
parent
a004f25a56
commit
ce5b29ed63
@ -23,6 +23,11 @@ import getBuildScript from '../../utils/getBuildScript';
|
|||||||
import fetchNpmTarball from '../../utils/fetchNpmTarball';
|
import fetchNpmTarball from '../../utils/fetchNpmTarball';
|
||||||
|
|
||||||
async function buildNetlify(options) {
|
async function buildNetlify(options) {
|
||||||
|
if (process.env.NETLIFY === 'true') {
|
||||||
|
options.printTimestamp = false;
|
||||||
|
options.printColor = false;
|
||||||
|
}
|
||||||
|
|
||||||
const context = await createContext(options);
|
const context = await createContext(options);
|
||||||
const netlifyDir = path.resolve(context.baseDirectory, './.lowdefy/netlify');
|
const netlifyDir = path.resolve(context.baseDirectory, './.lowdefy/netlify');
|
||||||
|
|
||||||
|
@ -20,12 +20,15 @@ import createPrint from './print';
|
|||||||
import { cacheDirectoryPath, outputDirectoryPath } from './directories';
|
import { cacheDirectoryPath, outputDirectoryPath } from './directories';
|
||||||
|
|
||||||
async function createContext(options = {}) {
|
async function createContext(options = {}) {
|
||||||
const context = {
|
const context = {};
|
||||||
baseDirectory: path.resolve(options.baseDirectory || process.cwd()),
|
|
||||||
print: createPrint({ timestamp: true }),
|
|
||||||
};
|
|
||||||
context.cacheDirectory = path.resolve(context.baseDirectory, cacheDirectoryPath);
|
|
||||||
|
|
||||||
|
context.print = createPrint({
|
||||||
|
timestamp: options.printTimestamp != null ? options.printTimestamp : true,
|
||||||
|
color: options.printColor != null ? options.color : true,
|
||||||
|
});
|
||||||
|
|
||||||
|
context.baseDirectory = path.resolve(options.baseDirectory || process.cwd());
|
||||||
|
context.cacheDirectory = path.resolve(context.baseDirectory, cacheDirectoryPath);
|
||||||
if (options.outputDirectory) {
|
if (options.outputDirectory) {
|
||||||
context.outputDirectory = path.resolve(options.outputDirectory);
|
context.outputDirectory = path.resolve(options.outputDirectory);
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,16 +17,17 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
const printToTerminal = (color, options = {}) => (text) => {
|
const printToTerminal = (color, options = {}) => (text) => {
|
||||||
let message;
|
let message = text;
|
||||||
|
if (options.color) {
|
||||||
|
message = color(message);
|
||||||
|
}
|
||||||
if (options.timestamp) {
|
if (options.timestamp) {
|
||||||
const time = new Date(Date.now());
|
const time = new Date(Date.now());
|
||||||
const h = time.getHours();
|
const h = time.getHours();
|
||||||
const m = time.getMinutes();
|
const m = time.getMinutes();
|
||||||
const s = time.getSeconds();
|
const s = time.getSeconds();
|
||||||
const timeString = `${h > 9 ? '' : '0'}${h}:${m > 9 ? '' : '0'}${m}:${s > 9 ? '' : '0'}${s}`;
|
const timeString = `${h > 9 ? '' : '0'}${h}:${m > 9 ? '' : '0'}${m}:${s > 9 ? '' : '0'}${s}`;
|
||||||
message = `${chalk.dim(timeString)} - ${color(text)}`;
|
message = `${chalk.dim(timeString)} - ${message}`;
|
||||||
} else {
|
|
||||||
message = color(text);
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(message);
|
console.log(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user