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';
|
||||
|
||||
async function buildNetlify(options) {
|
||||
if (process.env.NETLIFY === 'true') {
|
||||
options.printTimestamp = false;
|
||||
options.printColor = false;
|
||||
}
|
||||
|
||||
const context = await createContext(options);
|
||||
const netlifyDir = path.resolve(context.baseDirectory, './.lowdefy/netlify');
|
||||
|
||||
|
@ -20,12 +20,15 @@ import createPrint from './print';
|
||||
import { cacheDirectoryPath, outputDirectoryPath } from './directories';
|
||||
|
||||
async function createContext(options = {}) {
|
||||
const context = {
|
||||
baseDirectory: path.resolve(options.baseDirectory || process.cwd()),
|
||||
print: createPrint({ timestamp: true }),
|
||||
};
|
||||
context.cacheDirectory = path.resolve(context.baseDirectory, cacheDirectoryPath);
|
||||
const context = {};
|
||||
|
||||
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) {
|
||||
context.outputDirectory = path.resolve(options.outputDirectory);
|
||||
} else {
|
||||
|
@ -17,16 +17,17 @@
|
||||
import chalk from 'chalk';
|
||||
|
||||
const printToTerminal = (color, options = {}) => (text) => {
|
||||
let message;
|
||||
let message = text;
|
||||
if (options.color) {
|
||||
message = color(message);
|
||||
}
|
||||
if (options.timestamp) {
|
||||
const time = new Date(Date.now());
|
||||
const h = time.getHours();
|
||||
const m = time.getMinutes();
|
||||
const s = time.getSeconds();
|
||||
const timeString = `${h > 9 ? '' : '0'}${h}:${m > 9 ? '' : '0'}${m}:${s > 9 ? '' : '0'}${s}`;
|
||||
message = `${chalk.dim(timeString)} - ${color(text)}`;
|
||||
} else {
|
||||
message = color(text);
|
||||
message = `${chalk.dim(timeString)} - ${message}`;
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message);
|
||||
|
Loading…
Reference in New Issue
Block a user