MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / processFilesForUninstall

Function processFilesForUninstall

lib/models/blueprint.js:921–965  ·  view source on GitHub ↗

@method processFilesForUninstall @param {String} intoDir @param {Object} templateVariables

(intoDir, templateVariables)

Source from the content-addressed store, hash-verified

919 @param {Object} templateVariables
920 */
921 processFilesForUninstall(intoDir, templateVariables) {
922 let fileInfos = this._getFileInfos(this.files(this.options), intoDir, templateVariables);
923
924 this._ignoreUpdateFiles();
925
926 fileInfos = fileInfos.filter(isValidFile).reduce((acc, info) => {
927 // if it's possible that this blueprint could have produced either typescript OR javascript, we have to do some
928 // work to figure out which files to delete.
929 if (this.shouldTransformTypeScript) {
930 if (this.options.typescript === true) {
931 // if the user explicitly passed `--typescript`, we only want to delete TS files, so we stick with the existing
932 // info object since it will contain a .ts outputPath (since we know this blueprint is authored in TS because
933 // of our check above)
934 acc.push(info);
935 return acc;
936 }
937
938 const jsInfo = new FileInfo({
939 ...info,
940 outputPath: replaceTypeScriptExtension(info.outputPath),
941 displayPath: replaceTypeScriptExtension(info.displayPath),
942 });
943
944 if (this.options.typescript === false) {
945 // if the user explicitly passed `--no-typescript`, we only want to delete JS file, so we return our newly
946 // created jsInfo object since it contains the javascript version of the output path.
947 acc.push(jsInfo);
948 return acc;
949 }
950
951 if (this.options.typescript === undefined) {
952 // if the user didn't specify one way or the other, then both the JS and TS paths are possibilities, so we add
953 // both of them to the list. `finishProcessingForUninstall` will actually look to see which of them exists and
954 // delete whatever it finds.
955 acc.push(info, jsInfo);
956 return acc;
957 }
958 }
959
960 acc.push(info);
961 return acc;
962 }, []);
963
964 return finishProcessingForUninstall(fileInfos);
965 },
966
967 /**
968 @method mapFile

Callers

nothing calls this directly

Calls 3

filterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…