Add Subversion revision to included Javascript and CSS files - javascript

I'm looking adding Subversion's revision number to the name of each .js file we include, so whenever the .js file is updated, the browsers will automatically fetch the new version.
I believe Stackoverflow does this, but I wonder how. Is this part of the release procedure? Any hints on how to achieve this using Subversion tools?

There is no standard way to have Subversion add the revision to the file name. Use a build tool (for example, ant) and a custom target for this.

If you set the SVN Keyword "Revision" on the file which declares the tag, then the literal text $Revision$ becomes a SVN keyword. Each time you update the working copy, $Revision$ will update to read $Revision 1234 $ where 1234 is the current revision number.
Just be forewarned, we have run into problems with IE6 using this approach. We had put for all our tags (and applied the SVN Revision keyword to them) so that every time we push a new copy of code out to our production boxes, we know all clients will get the current revision. But IE6 sometimes creates weird errors when this happens; as though you were missing some of those script tags. In the end we took them out because it caused us more problems with IE6 than it ever solved us.

Related

Visual Studio Code Intellisense Method Definitions Javascript

Apparently no one else has wanted this feature, or I'm missing something. Intellisense works as normal, but I'm wondering if I'm missing a setting somewhere, if there is an extension, or if this functionality just isn't offered in VS Code... I would like to have the purpose of the method display when I start typing it as you can see in Adobe Brackets:
As opposed to how it shows in VS Code(which just shows the parameter requirements):
Is this possible?
VSCode is able to use the typescript language server to infer some information about the javascript that you're writing. The types for window/document etc are provided by the typescript team.
Here's where the type information for elements comes from. Compare that with the types for the document object. Notice that the properties here have comments above them, while the element properties do not. Type document.getElementById in VSCode, you'll see extra info like you do in brackets:
So for this information to appear about properties on Elements, someone would need to go through and add the comments. I have no idea if the typescript team is open to this, though.

Intesllisense methods for expect incorrect

When using intellisense in VS-Code, it gives autocomplete suggestions for an older version of expect than what I'm using,. The API has changed since it was donated to the Jest project, but for some reason, it still shows the old methods, but none of the replacement methods, like toHaveProperty.
Took a lot of effort to find out why my tests weren't working, but haven't been able to find an answer as to what could be the cause.
VS Code sources its type definitions for JavaScript from the #types namespace on NPM, which contains definition files that are automatically pulled from the DefinitelyTyped GitHub repository.
In your case, the type definitions will be coming from the #types/expect package, which specifies in the README that it exposes the files from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/expect.
If you look at the timestamps on said files, you'll notice they haven't been updated in 5 months! That is most likely the source of your issue.
You (or someone else) will need to submit an updated type definition to make automatic type acquisition function properly for that library. Alternatively, you can override the type definitions locally or disable the feature altogether.

Syntax folding in JavaScript files does not work in Vim

I've started using Vim 7.4 on Ubuntu and am very pleased with it but there is just one thing driving me crazy: code folding doesn't work (at least for JavaScript)!
The syntax is automatically set to JavaScript when a js file is opened and syntax highlight works so I don't get it. The foldmethod is initially set to "manual" and setting it to "syntax" doesn't make a difference, which puzzles me. I did add let javaScript_fold=1 to my .vimrc file.
Any clue? I'd be very grateful. Thanks!
It's tough to say the exact cause of this issue, but if you don't have a javascript.vim file you probably should. I suggest starting with this enhanced javascript syntax config. It is likely to fix your javascript folding issue, and much more.
If you just want to focus on the folding issue you might try creating your own javascript.vim file in ~/.vim/syntax/javascript.vim that contains code along the lines of what I have given below. You may want to adjust the fold level to your liking (0 is completely folded). However, this simple version will not play well with comments containing curly bracket characters, which is where you will want to go with a more robust javascript.vim like the one I have linked.
syntax region foldBraces start=/{/ end=/}/ transparent fold keepend extend
setlocal foldmethod=syntax
setlocal foldlevel=0
I should add that both myself and the other responder are suggesting that you need a javascript.vim, and in fact by some of the same contributors. However, the one I am suggesting was last updated in December of 2015 as opposed to 2009.
I don't know why your solution isn't working, but a possible solution is to use a user-created vimscript available at http://www.vim.org/scripts/script.php?script_id=1491
Just had this same issue answered on Vim Stack Exchange, and the answer is that if you do use the stock syntax/javascript.vim file, then you have to set
vv
let g:javaScript_fold = 1
^^
The difference between the command in the question and here is the g: part (highlighted above). I'm new to Vim scripting, but I believe the difference is that let javaScript_fold=1 sets a script-local variable, making it confined to your .vimrc file, and the example above makes it global (which seems to be confirmed by this Stackoverflow thread). See more on this at section 41.2 Variables in :help usr_41.txt and :help internal-variables.
This Reddit thread was also enlightening; it's not JavaScript-related but the folding seems to be useful for JS files as well.

VS 2013 web essentials js bundle ignores output filename

It seems that all my questions are destined to have something to do with web essentials. This one is a bit weird. The bundle tag is defined like this:
<bundle minify="true" runOnBuild="true" output="planning-bundle.js">
and the file is named planning.js.bundle,
The thing is that on build it completely ignores the output name and creates a planning.js and planning.min.js instead of planning-bundle.js and planning-bundle.min.js. As a workaround I temporarily change the bundle name to planning-bundle.js.bundle.
I have vs2013 update 2, and latest webessentials. I have looked around in options for webessentials, but I cannot find where this could be controlled...I'd be grateful for any help here.
/Erik
Seems like the schema has changed and that output is abandoned in favor for outputDirectory. See the new format on http://vswebessentials.com/features/bundling. The other attributes are automatically converted to the new format, but output is just removed. So your workaround has become the permanent solution.

Renaming variables in JavaScript

I've been stuck with the unpleasant task of "unminifying" a minified JavaScript code file. Using JSBeautifier, the resulting file is about 6000 lines long.
Ordinarily, the variable and parameter names would be permanently lost, but in this case, I have an obsolete version of the original file that the minified JavaScript code file was generated from. This obsolete version of the original file contains most of the code comments and variable names, but absolutely cannot be used in place of the current version.
I would like to know if there is some way of renaming all instances of a particular parameter or variable in JavaScript. Since minification reduces the names to a single character, find-and-replace is impossible.
Is there some tool out there, which I can tell, in this file, the parameter a to function foo should be clientName and have it semantically rename all instances of that parameter to clientName?
Unfortunately, I work for a large organization with an approved list of software and I am stuck with Visual Studio 2010 for the forseeable future (no VS 2012).
Update: #Kos, we don't use Git, but we do use source control. The problem is that a developer who doesn't work for my organization anymore once made changes to the file, minified it, and only checked in the minified version to source control, so his changes to the original have been lost.
I'm a year late for this answer, but I had a similar problem to yours so I built this: https://github.com/zertosh/beautify-with-words. It unminifies code using UglifyJS2 but uses a phonetic word generator to rename variables. You get "long-ish" variable names so it's a breeze to do a find-and-replace. Hope this helps someone else!
You might have another way out.
Check out the last unminified version of the code. Compare to the minified version. Arguably most of it should be the same modulo consistent variable renaming. The differences you'll have to rename and remerge.
Diff won't do this kind of compare; you need tools that compare the programs as code, not text. Our SmartDifferencer tool will do this (by using language-specific full parsers to generate ASTs, and then comparing the ASTs); in effect, it compares the programs in spite of whitepspacing. SmartDifferencer also handles renaming; if two file are identical modulo a single renaming, that's what SmartDifferencer tell you.
I don't know how well this work work out; we haven't tried SmartDifferencer with 6000 lines of "consistently renamed" variables.
I found that a Visual Studio extension we've licensed here called "Telerik JustCode" has functionality to do what I want.

Categories