Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return process.env.XDG_CONFIG_HOME;
return os.homedir() + '/.config';
}
function getUserCacheDir() {
if (process.env.XDG_CACHE_HOME)
return process.env.XDG_CACHE_HOME;
return os.homedir() + '/.cache';
}
function getFilesDir() {
if (process.env.THINGENGINE_HOME)
return path.resolve(process.env.THINGENGINE_HOME);
else
return path.resolve(getUserConfigDir(), 'almond-test');
}
class Platform extends Tp.BasePlatform {
// Initialize the platform code
// Will be called before instantiating the engine
constructor(homedir) {
super();
homedir = homedir || getFilesDir();
this._assistant = null;
this._gettext = new Gettext();
this._filesDir = homedir;
safeMkdirSync(this._filesDir);
this._locale = 'en-US';
this._gettext.setLocale(this._locale);
this._timezone = 'America/Los_Angeles';
this._prefs = new MemoryPreferences();
function getGitConfig(key, _default) {
try {
const args = ['config', '--get', '--default', _default || '', key];
const stdout = child_process.execFileSync('git', args);
return String(stdout).trim() || _default;
} catch(e) {
// ignore error if git is not installed
if (e.code !== 'ENOENT')
throw e;
// also ignore error if the key
return _default;
}
}
class TestPlatform extends Tp.BasePlatform {
constructor() {
super();
this._thingpedia = new ThingpediaClient(this);
this._developerKey = getGitConfig('thingpedia.developer-key', process.env.THINGENGINE_DEVELOPER_KEY || null);
}
getDeveloperKey() {
return this._developerKey;
}
get type() {
return 'test';
}
get locale() {
return 'en-US';
for (let kind of kinds) {
const localPath = path.resolve(developerDir, kind, 'manifest.tt');
if (await util.promisify(fs.exists)(localPath))
handled[kind] = await this._getLocalFactory(localPath, kind);
else
forward.push(kind);
}
if (forward.length > 0)
handled.assign(await super.getDeviceSetup(forward));
return handled;
}
}
class Platform extends Tp.BasePlatform {
// Initialize the platform code
// Will be called before instantiating the engine
constructor(homedir) {
super();
homedir = homedir || getFilesDir();
this._assistant = null;
this._gettext = new Gettext();
this._filesDir = homedir;
safeMkdirSync(this._filesDir);
this._locale = process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || 'en-US';
// normalize this._locale to something that Intl can grok
this._locale = this._locale.split(/[-_.@]/).slice(0,2).join('-');
super();
}
newConnection(delegate) {
var wrapper = new WebSocketWrapper(delegate);
this.emit('connection', wrapper);
wrapper.on('close', () => {
delegate.$free();
wrapper.$free();
});
return wrapper;
}
}
WebSocketApi.prototype.$rpcMethods = ['newConnection'];
class Platform extends Tp.BasePlatform {
constructor(thingpediaClient, options) {
super();
this._cloudId = options.cloudId;
this._authToken = options.authToken;
this._developerKey = options.developerKey;
this._thingpediaClient = thingpediaClient;
this._locale = options.locale;
this._timezone = options.timezone;
this._sqliteKey = options.storageKey;
this._gettext = i18n.get(this._locale);
this._writabledir = _shared ? (process.cwd() + '/' + options.cloudId) : process.cwd();
try {
fs.mkdirSync(this._writabledir + '/cache');
} catch(e) {