-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix node not honoring NODE_PRESERVE_SYMLINKS
node 10 has --preserve-symlinks-main flag, but we are still supporting 8
- Loading branch information
Showing
6 changed files
with
142 additions
and
88 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
77 changes: 44 additions & 33 deletions
77
packages/electrode-archetype-react-app-dev/scripts/map-isomorphic-cdn.js
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,43 +1,54 @@ | ||
"use strict"; | ||
|
||
let appDir = process.cwd(); | ||
/* eslint-disable max-statements */ | ||
|
||
const logger = require("electrode-archetype-react-app/lib/logger"); | ||
const fs = require("fs"); | ||
const Path = require("path"); | ||
const isMain = require.main === module; | ||
|
||
if (process.argv[2]) { | ||
appDir = process.argv[2]; | ||
function exit(code) { | ||
if (isMain) process.exit(code); | ||
} | ||
|
||
const fs = require("fs"); | ||
const Path = require("path"); | ||
const isoConfigFile = Path.join(appDir, ".isomorphic-loader-config.json"); | ||
const cdnAssetsFile = Path.join(appDir, "config/assets.json"); | ||
const isoConfig = require(isoConfigFile); | ||
const cdnAssets = require(cdnAssetsFile); | ||
|
||
const uniques = Object.keys(cdnAssets).reduce((acc, k) => { | ||
const base = Path.dirname(cdnAssets[k]); | ||
acc[base] = acc[base] ? acc[base]++ : 1; | ||
return acc; | ||
}, {}); | ||
|
||
const paths = Object.keys(uniques); | ||
|
||
if (paths.length > 1) { | ||
logger.error("CDN upload files has different base paths"); | ||
paths.forEach(p => { | ||
logger.info(` - "${p}"`); | ||
}); | ||
process.exit(1); | ||
function mapIsomorphicCdn(appDir) { | ||
appDir = appDir || process.cwd(); | ||
const isoConfigFile = Path.join(appDir, ".isomorphic-loader-config.json"); | ||
const cdnAssetsFile = Path.join(appDir, "config/assets.json"); | ||
const isoConfig = require(isoConfigFile); | ||
const cdnAssets = require(cdnAssetsFile); | ||
|
||
const uniques = Object.keys(cdnAssets).reduce((acc, k) => { | ||
const base = Path.dirname(cdnAssets[k]); | ||
acc[base] = acc[base] ? acc[base]++ : 1; | ||
return acc; | ||
}, {}); | ||
|
||
const paths = Object.keys(uniques); | ||
|
||
if (paths.length > 1) { | ||
logger.error("CDN upload files has different base paths"); | ||
paths.forEach(p => { | ||
logger.info(` - "${p}"`); | ||
}); | ||
exit(1); | ||
} | ||
|
||
if (paths.length === 1) { | ||
let pp = paths[0].trim(); | ||
pp += pp.endsWith("/") ? "" : "/"; | ||
isoConfig.output.publicPath = pp; | ||
fs.writeFileSync(isoConfigFile, JSON.stringify(isoConfig, null, 2)); | ||
logger.info(`\n===\nISOMORPHIC loader config publicPath updated to CDN path ${pp}\n`); | ||
} else { | ||
logger.info(`No CDN path found from CDN assets file ${cdnAssetsFile}`); | ||
} | ||
|
||
exit(0); | ||
} | ||
|
||
if (paths.length === 1) { | ||
let pp = paths[0].trim(); | ||
pp += pp.endsWith("/") ? "" : "/"; | ||
isoConfig.output.publicPath = pp; | ||
fs.writeFileSync(isoConfigFile, JSON.stringify(isoConfig, null, 2)); | ||
logger.info(`\n===\nISOMORPHIC loader config publicPath updated to CDN path ${pp}\n`); | ||
} else { | ||
logger.info(`No CDN path found from CDN assets file ${cdnAssetsFile}`); | ||
if (isMain) { | ||
mapIsomorphicCdn(process.argv[2]); | ||
} | ||
|
||
process.exit(0); | ||
module.exports = mapIsomorphicCdn; |
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
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