@mongodb-js/mongodb-ui-components
Version:
A collection of frequently used functional UI components found on mongodb properties
37 lines (32 loc) • 1.09 kB
JavaScript
const fs = require('fs-extra')
const replace = require('replace-in-file')
fs.copy('build/nav', 'build/preact/nav', (err) => {
if (err) return console.error('copy: ' + err)
replaceText({
files: `build/preact/nav/**/*.js`,
from: `import React from 'react'`,
to: `import {h} from 'preact'`
}).then(() => replaceText({
files: `build/preact/nav/**/*.js`,
from: `import React, { Component } from 'react'`,
to: `import {h, Component} from 'preact'`
}).then(() => replaceText({
files: `build/preact/nav/**/*.js`,
from: /React.Component/g,
to: `Component`
}).then(() => replaceText({
files: `build/preact/nav/**/*.js`,
from: /React.createElement/g,
to: `h`
}).then(() => replaceText({
files: `build/preact/nav/**/*.js`,
from: `import { render } from 'react-dom'`,
to: `import {render} from 'preact'`
})))))
console.log('success!')
})
function replaceText (opts) {
return replace(opts)
.then(changes => console.log('Modified files:', changes.join(', ')))
.catch(error => console.error('Error occurred:', error))
}