如何防止在TypeScript项目中编辑生成的JavaScript文件? [英] How to prevent editing of generated Javascript files in a TypeScript project?

查看:113
本文介绍了如何防止在TypeScript项目中编辑生成的JavaScript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2012项目中是否有可能实施一项规则,防止开发人员试图直接编辑TypeScript文件生成的JavaScript文件(偶然/旧习惯)?



我有一个包含大量TypeScript文件的项目,这些文件反过来产生了大量必须包含在项目中的JavaScript文件。但是,我发现自己选择了习惯上的JavaScript文件,而不是选择Typescript版本的文件来进行编辑。我想阻止这一点。因为这些TypeScript / JavaScript文件是从别处链接而来的,所以我似乎无法嵌套它们。

该项目是一个Windows应用商店应用,带有WinJS。它有三个不同的Windows Store项目和一组共享的解决方案文件夹,其中包括大量的TypeScript / JavaScript文件,这些文件使用项目文件中的以下语法链接到项目中:

 < Content Include =.. \Shared\ ** \ *。*> 
< Link>%(RecursiveDir)%(FileName)%(Extension)< / Link>
< CopyToOutputDirectory> PreserveNewest< / CopyToOutputDirectory>
< / Content>

这允许我将Shared目录和子目录中的所有文件都包含为自动链接的文件。共享链接文件非常方便,但意味着我可以嵌套单个文件,因为递归文件链接会被破坏。



我的源代码控制是git。所以我想可能有一个选项来防止在git中编辑.js文件?寻找建议。

解决方案


所以我想可能有一个选项可以防止在git中编辑.js文件?


我们使用 .gitignore 。这些js文件再次构建为构建/部署的一部分。

这与您不包括 *。exe / *的方式类似.dll git仓库中的文件。


Is it possible in a Visual Studio 2012 project to enforce a rule that prevents developers from trying to directly edit (by accident/old habit) the JavaScript files generated by the TypeScript files?

I have a project with a lot of TypeScript files that have in turn generated a lot of JavaScript files that have to be included in the project. However, I find myself selecting the JavaScript files out of habit rather than selecting the Typescript version of file to do my editing. I'd like to prevent this. Because these TypeScript/JavaScript files are linked in from elsewhere, I can't seem to nest them.

The project is a Windows Store app with WinJS. It has three different Windows Store projects in it and a set of shared solution folders that include the bulk of the TypeScript/JavaScript files which are linked into the projects using the syntax below in the project files:

<Content Include="..\Shared\**\*.*">
  <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

This allows me to include all files in the Shared directory and sub-directories as automatically linked files. It's really handy for sharing linked files, but mean I can nest individual files because the recursive file linking would get broken.

My source control is git. So I suppose there might be an option to prevent editing the .js files in git? Looking for suggestions.

解决方案

So I suppose there might be an option to prevent editing the .js files in git?

We have the .js files excluded from the repo using .gitignore. These js files are built again as a part of build / deploy.

This is similar to the manner you wouldn't include *.exe / *.dll files in your git repo.

这篇关于如何防止在TypeScript项目中编辑生成的JavaScript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆