-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3491 from storybooks/new-angular-cli-integration
angular-cli 6 (with webpack 4) compatibility
- Loading branch information
Showing
31 changed files
with
979 additions
and
1,070 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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import fs from 'fs'; | ||
import { basename, dirname, normalize, relative, resolve } from '@angular-devkit/core'; | ||
|
||
function isDirectory(assetPath) { | ||
try { | ||
return fs.statSync(assetPath).isDirectory(); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
function getAssetsParts(resolvedAssetPath, assetPath) { | ||
if (isDirectory(resolvedAssetPath)) { | ||
return { | ||
glob: '**/*', // Folders get a recursive star glob. | ||
input: assetPath, // Input directory is their original path. | ||
}; | ||
} | ||
|
||
return { | ||
glob: basename(assetPath), // Files are their own glob. | ||
input: dirname(assetPath), // Input directory is their original dirname. | ||
}; | ||
} | ||
|
||
export function isBuildAngularInstalled() { | ||
try { | ||
require.resolve('@angular-devkit/build-angular'); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
export function normalizeAssetPatterns(assetPatterns, dirToSearch, sourceRoot) { | ||
if (!assetPatterns || !assetPatterns.length) { | ||
return []; | ||
} | ||
|
||
return assetPatterns.map(assetPattern => { | ||
const assetPath = normalize(assetPattern); | ||
const resolvedSourceRoot = resolve(dirToSearch, sourceRoot); | ||
const resolvedAssetPath = resolve(dirToSearch, assetPath); | ||
const parts = getAssetsParts(resolvedAssetPath, assetPath); | ||
|
||
// Output directory for both is the relative path from source root to input. | ||
const output = relative(resolvedSourceRoot, resolve(dirToSearch, parts.input)); | ||
|
||
// Return the asset pattern in object format. | ||
return { | ||
...parts, | ||
output, | ||
}; | ||
}); | ||
} |
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 was deleted.
Oops, something went wrong.
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.