rokucommunity / ropm

A package manager for the Roku platform.
MIT License
34 stars 6 forks source link

Support observeFieldScoped prefixing #20

Closed iObject closed 3 years ago

iObject commented 3 years ago

Add autoprefixing to observeFieldScoped. This method is similar to the observeField() method.

https://developer.roku.com/en-ca/docs/references/brightscript/interfaces/ifsgnodefield.md#observefieldscopedfieldname-as-string-functionname-as-string-infofields-as-object-as-boolean

TwitchBronBron commented 3 years ago

Yep, definitely missed that function. This should be a pretty easy fix. Rather than making a whole separate function to find this, we could just update the regular expression for observerField to support both.

https://github.com/rokucommunity/ropm/blob/74ea5a525835cfe7ef12699bd56406194f99530a/src/prefixer/File.ts#L342

const regexp = /(\.observeField[ \t]*\(.*?,[ \t]*")([a-z0-9_]+)"\)[ \t]*(?:'.*)*$/gim;

becomes

const regexp = /(\.observeField(?:Scoped)?[ \t]*\(.*?,[ \t]*")([a-z0-9_]+)"\)[ \t]*(?:'.*)*$/gim;

Haven't tested that, but should do the trick. We'll want to add a few unit tests to verify it works.