Switch to FUI nightly

This commit is contained in:
Jay Trees 2022-04-07 09:06:43 +02:00
parent 0ea1ad469d
commit ec5b6c905c
6595 changed files with 171884 additions and 136424 deletions

View file

@ -1,29 +1,37 @@
/* global process */
'use strict'
var fs = require('fs')
var path = require('path')
var findup = require('@choojs/findup')
var stripJSONComments = require('strip-json-comments')
var config = {}
var configSources = ['package.json', '.rtlcssrc', '.rtlcss.json']
module.exports.load = function (configFilePath, cwd, overrides) {
const fs = require('fs')
const path = require('path')
const findUp = require('find-up')
const stripJSONComments = require('strip-json-comments')
let config = {}
const configSources = ['package.json', '.rtlcssrc', '.rtlcss.json']
const environments = [
process.env.USERPROFILE,
process.env.HOMEPATH,
process.env.HOME
]
const readConfig = (configFilePath) => {
return JSON.parse(stripJSONComments(fs.readFileSync(configFilePath, 'utf-8').trim()))
}
module.exports.load = (configFilePath, cwd, overrides) => {
if (configFilePath) {
return override(
JSON.parse(
stripJSONComments(
fs.readFileSync(configFilePath, 'utf-8').trim())), overrides)
return override(readConfig(configFilePath), overrides)
}
var directory = cwd || process.cwd()
const directory = cwd || process.cwd()
config = loadConfig(directory)
if (!config) {
var evns = [process.env.USERPROFILE, process.env.HOMEPATH, process.env.HOME]
for (var x = 0; x < evns.length; x++) {
if (!evns[x]) {
for (const environment of environments) {
if (!environment) {
continue
}
config = loadConfig(evns[x])
config = loadConfig(environment)
if (config) {
break
}
@ -33,27 +41,27 @@ module.exports.load = function (configFilePath, cwd, overrides) {
if (config) {
override(config, overrides)
}
return config
}
function loadConfig (dir) {
for (var x = 0; x < configSources.length; x++) {
var found
var source = configSources[x]
function loadConfig (cwd) {
for (const source of configSources) {
let foundPath
try {
found = findup.sync(dir, source)
foundPath = findUp.sync(source, { cwd })
} catch (e) {
continue
}
if (found) {
var configFilePath = path.normalize(path.join(found, source))
if (foundPath) {
const configFilePath = path.normalize(foundPath)
try {
config = JSON.parse(
stripJSONComments(
fs.readFileSync(configFilePath, 'utf-8').trim()))
config = readConfig(configFilePath)
} catch (e) {
throw new Error(e + ' ' + configFilePath)
throw new Error(`${e} ${configFilePath}`)
}
if (source === 'package.json') {
@ -69,13 +77,16 @@ function loadConfig (dir) {
function override (to, from) {
if (to && from) {
for (var p in from) {
if (typeof to[p] === 'object') {
override(to[p], from[p])
} else {
to[p] = from[p]
for (const p in from) {
if (Object.prototype.hasOwnProperty.call(from, p)) {
if (Object.prototype.hasOwnProperty.call(to, p) && typeof to[p] === 'object') {
override(to[p], from[p])
} else {
to[p] = from[p]
}
}
}
}
return to
}