Skip to content

Commit

Permalink
Adds support for parsing JSON with BOM to 'spfx project upgrade'. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
rabwill authored and waldekmastykarz committed Sep 12, 2020
1 parent 8dcf3bd commit ff26321
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Utils.ts
Expand Up @@ -705,4 +705,8 @@ export default class Utils {
});
});
}

public static parseJsonWithBom(s: string): any {
return JSON.parse(s.replace(/^\uFEFF/, ''));
}
}
3 changes: 2 additions & 1 deletion src/m365/spfx/commands/project/base-project-command.ts
@@ -1,6 +1,7 @@
import Command from "../../../../Command";
import { TsFile, Manifest, Project, ScssFile } from "./model";
import { Utils } from './project-upgrade/';
import GlobalUtils from '../../../../Utils';
import * as path from 'path';
import * as fs from 'fs';

Expand Down Expand Up @@ -137,7 +138,7 @@ export abstract class BaseProjectCommand extends Command {
const manifestFiles = srcFiles.filter(f => f.endsWith('.manifest.json'));
const manifests: Manifest[] = manifestFiles.map((f) => {
const manifestStr = Utils.removeSingleLineComments(fs.readFileSync(f, 'utf-8'));
const manifest: Manifest = JSON.parse(manifestStr);
const manifest: Manifest = GlobalUtils.parseJsonWithBom(manifestStr);
manifest.path = f;
return manifest;
});
Expand Down

0 comments on commit ff26321

Please sign in to comment.