fix(@angular/cli): allow update when git is unclean outside the workspace

This commit is contained in:
Charles Lyding 2019-06-10 21:32:01 -04:00 committed by Keen Yee Liau
parent efe463371d
commit 09149fe5e4

View File

@ -346,10 +346,24 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
checkCleanGit() { checkCleanGit() {
try { try {
const result = execSync('git status --porcelain', { encoding: 'utf8', stdio: 'pipe' }); const result = execSync('git status --porcelain', { encoding: 'utf8', stdio: 'pipe' });
if (result.trim().length === 0) {
return true;
}
return result.trim().length === 0; // Only files inside the workspace root are relevant
} catch { for (const entry of result.split('\n')) {
return true; const relativeEntry = path.relative(
} path.resolve(this.workspace.root),
path.resolve(entry.slice(3).trim()),
);
if (!relativeEntry.startsWith('..') && !path.isAbsolute(relativeEntry)) {
return false;
}
}
} catch { }
return true;
} }
} }