Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_initConfigAndCollectFileNames(configFileName) {
var configDir = path.dirname(configFileName);
var configSrc = fs.readFileSync(configFileName, 'utf-8');
try {
var config = (configSrc && configSrc.trim().length) ? JSON.parse(configSrc) : {};
config.basePath = configDir; // assumes 'stackblitz.json' is at `/src` level.
} catch (e) {
throw new Error(`Stackblitz config - unable to parse json file: ${configFileName}\n${e}`);
}
var defaultIncludes = ['**/*.ts', '**/*.js', '**/*.css', '**/*.html', '**/*.md', '**/*.json', '**/*.png', '**/*.svg'];
var boilerplateIncludes = ['src/environments/*.*', 'angular.json', 'src/polyfills.ts'];
if (config.files) {
if (config.files.length > 0) {
if (config.files[0].substr(0, 1) == '!') {
config.files = defaultIncludes.concat(config.files);
}
}
if ( !getLinkInfoImpl.useFirstAmbiguousLink && docs.length > 1 ) {
linkInfo.valid = false;
linkInfo.errorType = 'ambiguous';
linkInfo.error = 'Ambiguous link: "' + url + '".\n' +
docs.reduce(function(msg, doc) { return msg + '\n "' + doc.id + '" ('+ doc.docType + ') : (' + doc.path + ' / ' + doc.fileInfo.relativePath + ')'; }, 'Matching docs: ');
} else if ( docs.length >= 1 ) {
linkInfo.url = docs[0].path;
linkInfo.title = title || encodeCodeBlock(docs[0].name, true);
linkInfo.type = 'doc';
if ( getLinkInfoImpl.relativeLinks && currentDoc && currentDoc.path ) {
var currentFolder = path.dirname(currentDoc.path);
var docFolder = path.dirname(linkInfo.url);
var relativeFolder = path.relative(path.join('/', currentFolder), path.join('/', docFolder));
linkInfo.url = path.join(relativeFolder, path.basename(linkInfo.url));
log.debug(currentDoc.path, docs[0].path, linkInfo.url);
}
} else if ( url.indexOf('#') > 0 ) {
var pathAndHash = url.split('#');
linkInfo = getLinkInfoImpl(pathAndHash[0], title, currentDoc);
linkInfo.url = linkInfo.url + '#' + pathAndHash[1];
return linkInfo;
} else if ( url.indexOf('/') === -1 && url.indexOf('#') !== 0 ) {
linkInfo.valid = false;
linkInfo.errorType = 'missing';
if (!getLinkInfoImpl.useFirstAmbiguousLink && docs.length > 1) {
linkInfo.valid = false;
linkInfo.errorType = 'ambiguous';
linkInfo.error = 'Ambiguous link: "' + url + '".\n' + docs.reduce(function(msg, doc) {
return msg + '\n "' + doc.id + '" (' + doc.docType + ') : (' + doc.path + ' / ' +
doc.fileInfo.relativePath + ')';
}, 'Matching docs: ');
} else if (docs.length >= 1) {
linkInfo.url = docs[0].path;
linkInfo.title = title || docs[0].title || docs[0].name && encodeCodeBlock(docs[0].name, true);
linkInfo.type = 'doc';
if (getLinkInfoImpl.relativeLinks && currentDoc && currentDoc.path) {
var currentFolder = path.dirname(currentDoc.path);
var docFolder = path.dirname(linkInfo.url);
var relativeFolder =
path.relative(path.join('/', currentFolder), path.join('/', docFolder));
linkInfo.url = path.join(relativeFolder, path.basename(linkInfo.url));
log.debug(currentDoc.path, docs[0].path, linkInfo.url);
}
} else if (url.indexOf('#') > 0) {
var pathAndHash = url.split('#');
linkInfo = getLinkInfoImpl(pathAndHash[0], title, currentDoc);
linkInfo.url = linkInfo.url + '#' + pathAndHash[1];
return linkInfo;
} else if (url.indexOf('/') === -1 && url.indexOf('#') !== 0) {
linkInfo.valid = false;
linkInfo.errorType = 'missing';
defaultFn: function(doc) {
if ( doc.area === 'api' && doc.docType !== 'overview' ) {
return path.dirname(doc.fileInfo.relativePath).split('/')[0];
}
}
};
getOutputPath: function(doc) {
return path.join(
'partials',
path.dirname(doc.fileInfo.relativePath),
doc.fileInfo.baseName) + '.html';
}
});
function getMarkerPath(packageJsonPath: string, format: string) {
return resolve(dirname(packageJsonPath), `__modified_by_ngcc_for_${format}__`);
}
function ensureDirectoryExistence(filePath) {
var dirname = path.dirname(filePath);
if (directoryExists(dirname)) {
return true;
}
ensureDirectoryExistence(dirname);
fs.mkdirSync(dirname);
}
function ensureDirectoryExistence(filePath) {
var dirname = path.dirname(filePath);
if (directoryExists(dirname)) {
return true;
}
ensureDirectoryExistence(dirname);
fs.mkdirSync(dirname);
}
.map(packageJsonPath => {
const entryPointPackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
const entryPointPath: string|undefined = entryPointPackageJson[format];
if (!entryPointPath) {
return undefined;
}
const dtsEntryPointPath = entryPointPackageJson.typings || entryPointPath;
return new EntryPoint(dirname(packageJsonPath), entryPointPath, dtsEntryPointPath);
})
.filter(isDefined);