This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5514d98
commit a6459ad
Showing
9 changed files
with
8,932 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
const { promisify } = require('util') | ||
const copy = require('copy-dir') | ||
const rimraf = require('rimraf') | ||
const {promisify} = require('util') | ||
|
||
const getConfig = require('./get-config') | ||
|
||
// Filesystem | ||
const rimrafAsync = promisify(rimraf) | ||
|
||
const copyPromise = (source, dest) => new Promise((resolve, reject) => { | ||
copy(source, dest, (err) => { | ||
if (err) { | ||
reject(err) | ||
} | ||
const copyPromise = (source, dest) => | ||
new Promise((resolve, reject) => { | ||
copy(source, dest, err => { | ||
if (err) { | ||
reject(err) | ||
} | ||
|
||
resolve() | ||
}); | ||
}) | ||
resolve() | ||
}) | ||
}) | ||
|
||
module.exports = async () => { | ||
const {configFile, projectRoot, outputPath} = await getConfig() | ||
const { configFile, outputPath } = await getConfig() | ||
|
||
let themeConfig = {} | ||
try { | ||
themeConfig = require(configFile) | ||
} catch (err) { | ||
if(err.code !== 'MODULE_NOT_FOUND') { | ||
if (err.code !== 'MODULE_NOT_FOUND') { | ||
console.log(err) | ||
} | ||
} | ||
|
||
if(!themeConfig.distLocations) { | ||
if (!themeConfig.distLocations) { | ||
console.error('No `distLocations` defined in theme config') | ||
process.exit(1) | ||
return | ||
} | ||
|
||
const copies = themeConfig.distLocations.map(async (location) => { | ||
const copies = themeConfig.distLocations.map(async location => { | ||
await rimrafAsync(location) | ||
await copyPromise(outputPath, location) | ||
}) | ||
|
||
try { | ||
await Promise.all(copies) | ||
console.log('Copied to dist directory') | ||
await Promise.all(copies) | ||
console.log('Copied to dist directory') | ||
} catch (err) { | ||
console.error('Failed to copy dist directory') | ||
console.error(err) | ||
console.error('Failed to copy dist directory') | ||
console.error(err) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
const findUp = require('find-up') | ||
const path = require('path') | ||
const findUp = require('find-up') | ||
|
||
module.exports = async () => { | ||
const configFile = await findUp('aviate.config.js') | ||
|
||
if(!configFile) { | ||
if (!configFile) { | ||
const wepackConfigFile = await findUp('wepack.config.js') | ||
if(wepackConfigFile) { | ||
throw new Error('`wepack.config.js` found. Please rename to `aviate.config.js`') | ||
if (wepackConfigFile) { | ||
throw new Error( | ||
'`wepack.config.js` found. Please rename to `aviate.config.js`' | ||
) | ||
} | ||
} | ||
|
||
if(!configFile) { | ||
throw new Error('`aviate.config.js` not found') | ||
if (!configFile) { | ||
throw new Error('`aviate.config.js` not found') | ||
} | ||
|
||
const projectRoot = path.dirname(configFile) | ||
const outputPath = path.join(projectRoot, '.aviate') | ||
|
||
return {configFile, projectRoot, outputPath} | ||
} | ||
return { configFile, projectRoot, outputPath } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.